WriteRes.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:142k
源码类别:

MTK

开发平台:

C/C++

  1.  *  Load_Audio_Data
  2.  * DESCRIPTION
  3.  *  load and write audio header and data
  4.  * PARAMETERS
  5.  *  offset                  [OUT]       File offset --> file offset
  6.  *  output_file             [IN]        -> Name of the file to which buffer
  7.  *  input_file              [IN]        ->  Name of the input audio file
  8.  *  pImgData                [OUT]       -> buffer containing image data
  9.  *  audio_identifier        [IN]        -> audio identifier
  10.  *  is(?)                   [IN]        To be written
  11.  * RETURNS
  12.  *  S32 --> file size
  13.  *****************************************************************************/
  14. S32 Load_Audio_Data(U32 *offset, FILE *output_file, FILE *input_file, U8 *pImgData, U8 audio_identifier)
  15. {
  16.     /*----------------------------------------------------------------*/
  17.     /* Local Variables                                                */
  18.     /*----------------------------------------------------------------*/
  19.     U32 file_size, i, o = 0;
  20.     U8 ch;
  21.     /*----------------------------------------------------------------*/
  22.     /* Code Body                                                      */
  23.     /*----------------------------------------------------------------*/
  24.     fseek(input_file, 0, SEEK_END);
  25.     file_size = ftell(input_file);
  26.     fseek(input_file, 0, SEEK_SET);
  27.     if (toolFlag)
  28.     {
  29.         fprintf(
  30.             dest_file,
  31.             "%c%c%c%c%c%c%c%c",
  32.             audio_identifier,
  33.             file_size & 0xff,
  34.             (file_size & 0xff00) >> 8,
  35.             (file_size & 0xff0000) >> 16,
  36.             (file_size & 0xff000000) >> 24,
  37.             0,
  38.             0,
  39.             0);
  40.     }
  41.     else
  42.     {
  43.         fprintf(
  44.             output_file /* output_data_file */ ,
  45.             "nt0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x00, 0x00, 0x00,nt",
  46.             audio_identifier,
  47.             file_size & 0xff,
  48.             (file_size & 0xff00) >> 8,
  49.             (file_size & 0xff0000) >> 16,
  50.             (file_size & 0xff000000) >> 24);
  51.     }
  52.     pImgData[0] = (U8) audio_identifier;
  53.     pImgData[1] = (U8) (file_size & 0xff);
  54.     pImgData[2] = (U8) ((file_size & 0xff00) >> 8);
  55.     pImgData[3] = (U8) ((file_size & 0xff0000) >> 16);
  56.     pImgData[4] = (U8) ((file_size & 0xff000000) >> 24);
  57.     for (i = 0; i < file_size; i++)
  58.     {
  59.         ch = fgetc(input_file);
  60.         if (toolFlag)
  61.         {
  62.             fputc(ch, dest_file);
  63.             (*offset)++;
  64.             (pImgData)[i + 6] = ch;
  65.         }
  66.         else
  67.         {
  68.             fprintf(output_file, "0x%02X, ", ch);
  69.             (*offset)++;
  70.             (pImgData)[i + 6] = ch;
  71.             o++;
  72.             if ((o % 16) == 0)
  73.             {
  74.                 fprintf(output_file, "nt");
  75.             }
  76.         }
  77.     }
  78.     return file_size + 8;
  79. }
  80. /* 101205 audio resource Calvin End */
  81. /*****************************************************************************
  82.  * FUNCTION
  83.  *  Write_Sequential_Image_Header
  84.  * DESCRIPTION
  85.  *  Construct the header for sequential images
  86.  * PARAMETERS
  87.  *  output_file             [IN]        -> output file handle
  88.  *  image_identifier        [IN]        -> sequential image type
  89.  *  n_frames                [IN]        -> the number of the frames
  90.  *  seq_filesize            [IN]        -> pointer to a list of file sizes
  91.  *  seq_offset              [OUT]       -> pointer to a list of offsets
  92.  * RETURNS
  93.  *  void
  94.  *****************************************************************************/
  95. void Write_Sequential_Image_Header(
  96.         FILE *output_file,
  97.         U8 image_identifier,
  98.         S32 n_frames,
  99.         S32 *seq_filesize,
  100.         S32 *seq_offset)
  101. {
  102.     /*----------------------------------------------------------------*/
  103.     /* Local Variables                                                */
  104.     /*----------------------------------------------------------------*/
  105.     S32 i;
  106.     S32 offset = 8;
  107.     S32 real_size;
  108.     /*----------------------------------------------------------------*/
  109.     /* Code Body                                                      */
  110.     /*----------------------------------------------------------------*/
  111.     if (toolFlag == 1)
  112.     {
  113.         fprintf(dest_file, "%c%c%c%c%c%c%c%c", image_identifier, n_frames, 0, 0, 0, 0, 0, 0);   /* the major header */
  114.         for (i = 0; i < n_frames; i++)
  115.         {
  116.             int interval = sequential_interval[i];
  117.             seq_offset[i] = offset;
  118.             real_size = ((seq_filesize[i] + 3) >> 2) << 2;
  119.             fprintf(dest_file, "%c%c%c%c", seq_offset[i] & 0xff, (seq_offset[i] & 0xff00) >> 8, (seq_offset[i] & 0xff0000) >> 16, (seq_offset[i] & 0xff000000) >> 24);  /* the offset for each file */
  120.             fprintf(dest_file, "%c%c%c%c", seq_filesize[i] & 0xff, (seq_filesize[i] & 0xff00) >> 8, (seq_filesize[i] & 0xff0000) >> 16, (seq_filesize[i] & 0xff000000) >> 24);  /* the size for each file */
  121.             fprintf(dest_file, "%c%c%c%c", interval & 0xff, (interval & 0xff00) >> 8, (interval & 0xff0000) >> 16, (interval & 0xff000000) >> 24);      /* the interval for each file */
  122.             offset += real_size;
  123.         }
  124.     }
  125. /* 100206 ENFB support Start */
  126. #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  127.     else if (enfbFlag == 1) /* write ENFB header to CustImgDataxxx.h and image header/data to ENFB image data file */
  128.     {
  129.         S32 data_size = 0;
  130.         for (i = 0; i < n_frames; i++)
  131.         {
  132.             real_size = ((seq_filesize[i] + 3) >> 2) << 2;
  133.             data_size += real_size;
  134.         }
  135.         enfb_size = 8 + 12*n_frames + data_size;
  136.         
  137.         /* write ENFB header to CustImgDataxxx.h */
  138.         fprintf(
  139.             output_file,
  140.             "nt0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02Xt",
  141.             (U8) 255,//type
  142.             (U8) ENFBAssociatedIDAdded,//associated id
  143.             (U8) 0,//reserved
  144.             (U8) 0,//reserved
  145.             (U8) (enfb_offset & 0xff),
  146.             (U8) ((enfb_offset >> 8) & 0xff),
  147.             (U8) ((enfb_offset >> 16) & 0xff),
  148.             (U8) ((enfb_offset >> 24) & 0xff),
  149.             (U8) (enfb_size & 0xff),
  150.             (U8) ((enfb_size >> 8) & 0xff),
  151.             (U8) ((enfb_size >> 16) & 0xff),
  152.             (U8) ((enfb_size >> 24) & 0xff));
  153.         
  154.         /* image header/data to ENFB image data file */
  155.         fprintf(enfb_img_data_file, "%c%c%c%c%c%c%c%c", image_identifier, n_frames, 0, 0, 0, 0, 0, 0);   /* the major header */
  156.         for (i = 0; i < n_frames; i++)
  157.         {
  158.             int interval = sequential_interval[i];
  159.             seq_offset[i] = offset;
  160.             real_size = ((seq_filesize[i] + 3) >> 2) << 2;
  161.             fprintf(enfb_img_data_file, "%c%c%c%c", seq_offset[i] & 0xff, (seq_offset[i] & 0xff00) >> 8, (seq_offset[i] & 0xff0000) >> 16, (seq_offset[i] & 0xff000000) >> 24);  /* the offset for each file */
  162.             fprintf(enfb_img_data_file, "%c%c%c%c", seq_filesize[i] & 0xff, (seq_filesize[i] & 0xff00) >> 8, (seq_filesize[i] & 0xff0000) >> 16, (seq_filesize[i] & 0xff000000) >> 24);  /* the size for each file */
  163.             fprintf(enfb_img_data_file, "%c%c%c%c", interval & 0xff, (interval & 0xff00) >> 8, (interval & 0xff0000) >> 16, (interval & 0xff000000) >> 24);      /* the interval for each file */
  164.             offset += real_size;
  165.         }
  166.         
  167.         enfb_offset += enfb_size;
  168.     }
  169. #endif
  170. /* 100206 ENFB support End */  
  171.     else
  172.     {
  173.         fprintf(output_file, "nt0x%02X, 0x%02X, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,nt", image_identifier, n_frames);        /* the major header */
  174.         for (i = 0; i < n_frames; i++)
  175.         {
  176.             int interval = sequential_interval[i];
  177.             seq_offset[i] = offset;
  178.             real_size = ((seq_filesize[i] + 3) >> 2) << 2;
  179.             fprintf(output_file, "0x%02X, 0x%02X, 0x%02X, 0x%02X, ", seq_offset[i] & 0xff, (seq_offset[i] & 0xff00) >> 8, (seq_offset[i] & 0xff0000) >> 16, (seq_offset[i] & 0xff000000) >> 24);        /* the offset for each file */
  180.             fprintf(output_file, "0x%02X, 0x%02X, 0x%02X, 0x%02X, ", seq_filesize[i] & 0xff, (seq_filesize[i] & 0xff00) >> 8, (seq_filesize[i] & 0xff0000) >> 16, (seq_filesize[i] & 0xff000000) >> 24);        /* the size for each file */
  181.             fprintf(output_file, "0x%02X, 0x%02X, 0x%02X, 0x%02X,nt", interval & 0xff, (interval & 0xff00) >> 8, (interval & 0xff0000) >> 16, (interval & 0xff000000) >> 24); /* the interval for each file */
  182.             offset += real_size;
  183.             g_ressize += seq_filesize[i];
  184.         }
  185.     }
  186. }
  187. /*****************************************************************************
  188.  * FUNCTION
  189.  *  Write_Sequential_Image_File
  190.  * DESCRIPTION
  191.  *  Write raw date from a frame of an image to the output file
  192.  * PARAMETERS
  193.  *  output_file     [IN]        -> output file handle
  194.  *  input_file      [IN]        -> input file handle
  195.  *  filesize        [IN]        -> the input file size
  196.  * RETURNS
  197.  *  void
  198.  *****************************************************************************/
  199. void Write_Sequential_Image_File(FILE *output_file, FILE *input_file, S32 filesize)
  200. {
  201.     /*----------------------------------------------------------------*/
  202.     /* Local Variables                                                */
  203.     /*----------------------------------------------------------------*/
  204.     U32 i;
  205.     U32 o = 0;
  206.     U8 ch;
  207.     /*----------------------------------------------------------------*/
  208.     /* Code Body                                                      */
  209.     /*----------------------------------------------------------------*/
  210.     if (toolFlag == 1)
  211.     {
  212.         for (i = 0; i < filesize; i++)
  213.         {
  214.             ch = fgetc(input_file);
  215.             fprintf(dest_file, "%c", ch);
  216.         }
  217.         for (i = filesize; i % 4 != 0; i++)
  218.         {
  219.             fprintf(dest_file, "%c", 0);    /* for 4 byte alignment */
  220.         }
  221.     }
  222. /* 100206 ENFB support Start */
  223. #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  224.     else if (enfbFlag == 1) /* write ENFB header to CustImgDataxxx.h and image header/data to ENFB image data file */
  225.     {
  226.         for (i = 0; i < filesize; i++)
  227.         {
  228.             ch = fgetc(input_file);
  229.             fprintf(enfb_img_data_file, "%c", ch);
  230.         }
  231.         for (i = filesize; i % 4 != 0; i++)
  232.         {
  233.             fprintf(enfb_img_data_file, "%c", 0);    /* for 4 byte alignment */
  234.         }
  235.     }
  236. #endif
  237. /* 100206 ENFB support End */  
  238.     else
  239.     {
  240.         for (i = 0; i < filesize; i++)
  241.         {
  242.             ch = fgetc(input_file);
  243.             fprintf(output_file, "0x%02X, ", ch);
  244.             o++;
  245.             if ((o % 16) == 0)
  246.             {
  247.                 fprintf(output_file, "nt");
  248.             }
  249.         }
  250.         for (i = filesize; i % 4 != 0; i++)
  251.         {
  252.             fprintf(output_file, "0x00, "); /* for 4 byte alignment */
  253.         }
  254.         if ((o % 16) != 0)
  255.         {
  256.             fprintf(output_file, "nt");
  257.         }
  258.     }
  259. }
  260. /* Calvin end */
  261. /* __CUSTPACK_MULTIBIN Calvin END */
  262. /* 101205 audio resource Calvin Satrt */
  263. /*****************************************************************************
  264.  * FUNCTION
  265.  *  Extract_Name
  266.  * DESCRIPTION
  267.  *  Exract image name from the supplied string
  268.  * PARAMETERS
  269.  *  dest            [OUT]       -> Extrected file name from string
  270.  *  src             [IN]        -> string containing file name and path
  271.  *  res_type        [IN]        
  272.  * RETURNS
  273.  *  void
  274.  *****************************************************************************/
  275. void Extract_Name(S8 *dest, S8 *src, U32 res_type)
  276. {
  277.     /*----------------------------------------------------------------*/
  278.     /* Local Variables                                                */
  279.     /*----------------------------------------------------------------*/
  280.     U32 iLen = strlen(src);
  281.     U16 nCount = 0;
  282.     S8 *pSrc = src;
  283.     char a, b;
  284.     S8 *pCustPath;
  285.     U32 ExtFlag;
  286.     /*----------------------------------------------------------------*/
  287.     /* Code Body                                                      */
  288.     /*----------------------------------------------------------------*/
  289.     switch (res_type)
  290.     {
  291.         case RES_IMAGE:
  292.         case RES_MEDIA:
  293.         case RES_JAVA_GAME:
  294.             pCustPath = CustImgPath;
  295.             ExtFlag = ExtImageFlag;
  296.             break;
  297.         case RES_AUDIO:
  298.             pCustPath = CustAdoPath;
  299.             ExtFlag = ExtAudioFlag;
  300.             break;
  301.         default:
  302.             printf("res_type in Extract_Name is invalid!!");
  303.             pCustPath = CustImgPath;
  304.             ExtFlag = ExtImageFlag;
  305.             break;
  306.     }
  307.     iLen = strlen(pCustPath);
  308.     for (nCount = 0; nCount < iLen; nCount++)
  309.     {
  310.         a = toupper(pCustPath[nCount]);
  311.         b = toupper(src[nCount]);
  312.         if (a != b)
  313.         {
  314.             break;
  315.         }
  316.     }
  317.     if (iLen == nCount)
  318.     {
  319.         pSrc = &src[iLen];
  320.     }
  321.     iLen = strlen(pSrc);
  322.     nCount = 0;
  323.     while (iLen)
  324.     {
  325.         if ((pSrc[nCount] == '.') || (pSrc[nCount] == '-') || (pSrc[nCount] == ' ') || (pSrc[nCount] == '\'))
  326.         {
  327.             dest[nCount] = '_';
  328.         }
  329.         else
  330.         {
  331.             dest[nCount] = pSrc[nCount];
  332.         }
  333.         ++nCount;
  334.         --iLen;
  335.     }
  336.     /* __CUSTPACK_MULTIBIN Calvin BEGIN */
  337.     if (ExtFlag == 1)   /* 040805 CustPack: Calvin added */
  338.     {
  339.         dest[nCount] = '_'; /* add a '_' in the end to distinguish from the original */
  340.         dest[nCount + 1] = '';
  341.     }
  342.     /* __CUSTPACK_MULTIBIN Calvin END */
  343.     else
  344.     {
  345.         dest[nCount] = '';
  346.     }
  347.     return;
  348. }
  349. /* 101205 audio resource Calvin End */
  350. /* 101205 audio resource Calvin Satrt */
  351. /* 070306 Alpha layer Start */
  352. /*****************************************************************************
  353.  * FUNCTION
  354.  *  ExtractExtension
  355.  * DESCRIPTION
  356.  *  Function Extracting the extension
  357.  * PARAMETERS
  358.  *  src             [?]         
  359.  *  res_type        [IN]        -> resource type
  360.  *  string(?)       [IN]        -> string containing file name
  361.  * RETURNS
  362.  *  U8
  363.  *****************************************************************************/
  364. U8 ExtractExtension(S8 *src, U32 res_type)
  365. {
  366.     /*----------------------------------------------------------------*/
  367.     /* Local Variables                                                */
  368.     /*----------------------------------------------------------------*/
  369.     S32 i, j;
  370.     S32 type_number;
  371.     U8 ret = 0;
  372.     S8 *arr;
  373.     RESOURCE_INFO *pResource_info;
  374.     /*----------------------------------------------------------------*/
  375.     /* Code Body                                                      */
  376.     /*----------------------------------------------------------------*/
  377.     i = strlen(src) - 1;
  378.     arr = src+i;
  379.     for (j = 0; j < 5 ; j--)
  380.     {
  381.         if(*arr == '.')
  382.         {
  383.             arr++;
  384.             break;
  385.         }
  386.         else
  387.     {
  388.             arr--;
  389.         }
  390.     }
  391.     if(j >= 5)
  392.     {
  393.         return ret;
  394.     }
  395.     switch (res_type)
  396.     {
  397.         case RES_IMAGE:
  398.         case RES_MEDIA:
  399.             ret = IMAGE_TYPE_INVALID;
  400.             pResource_info = image_resource_info;
  401.             type_number = sizeof(image_resource_info) / sizeof(RESOURCE_INFO);
  402.             break;
  403.         case RES_AUDIO:
  404.             ret = AUDIO_TYPE_INVALID;
  405.             pResource_info = audio_resource_info;
  406.             type_number = sizeof(audio_resource_info) / sizeof(RESOURCE_INFO);
  407.             break;
  408.         default:
  409.             printf("res_type in Extract_Name is invalid!!");
  410.             ret = IMAGE_TYPE_INVALID;
  411.             pResource_info = image_resource_info;
  412.             type_number = sizeof(image_resource_info) / sizeof(RESOURCE_INFO);
  413.             break;
  414.     }
  415.     for (i = 0; i < type_number; i++)
  416.     {
  417.         if (!(strcmp(arr, pResource_info[i].filename_ext)))
  418.         {
  419.             ret = pResource_info[i].file_type;
  420.         }
  421.     }
  422.     return ret;
  423. }
  424. /*****************************************************************************
  425.  * FUNCTION
  426.  *  ChangeExtension
  427.  * DESCRIPTION
  428.  *  Function Change the extension
  429.  * PARAMETERS
  430.  *  src             [IN]        -> string containing file name 
  431.  *  res_type        [IN]        -> resource type
  432.  *  ext_type        [IN]        -> extension type
  433.  * RETURNS
  434.  *  BOOL
  435.  *****************************************************************************/
  436. BOOL ChangeExtension(S8 *src, U32 res_type, S32 ext_type)
  437. {
  438.     /*----------------------------------------------------------------*/
  439.     /* Local Variables                                                */
  440.     /*----------------------------------------------------------------*/
  441.     S32 i, j;
  442.     S32 type_number;
  443.     U8 ret = 0;
  444.     S8 *arr;
  445.     RESOURCE_INFO *pResource_info;
  446.     /*----------------------------------------------------------------*/
  447.     /* Code Body                                                      */
  448.     /*----------------------------------------------------------------*/
  449.     i = strlen(src) - 1;
  450.     arr = src+i;
  451.     for (j = 0; j < 5 ; j--)
  452.     {
  453.         if(*arr == '.')
  454.         {
  455.             arr++;
  456.             break;
  457.         }
  458.         else
  459.         {
  460.             arr--;
  461.         }
  462.     }
  463.     if (j >= 5)
  464.     {
  465.         return FALSE;
  466.     }
  467.     switch (res_type)
  468.     {
  469.         case RES_IMAGE:
  470.         case RES_MEDIA:
  471.             ret = IMAGE_TYPE_INVALID;
  472.             pResource_info = image_resource_info;
  473.             type_number = sizeof(image_resource_info) / sizeof(RESOURCE_INFO);
  474.             break;
  475.         case RES_AUDIO:
  476.             ret = AUDIO_TYPE_INVALID;
  477.             pResource_info = audio_resource_info;
  478.             type_number = sizeof(audio_resource_info) / sizeof(RESOURCE_INFO);
  479.             break;
  480.         default:
  481.             printf("res_type in Extract_Name is invalid!!");
  482.             ret = IMAGE_TYPE_INVALID;
  483.             pResource_info = image_resource_info;
  484.             type_number = sizeof(image_resource_info) / sizeof(RESOURCE_INFO);
  485.             break;
  486.     }
  487.     for (i = 0; i < type_number; i++)
  488.     {
  489.         if (pResource_info[i].file_type == ext_type)
  490.         {
  491.             break;
  492.         }
  493.     }
  494.     if (i >= type_number)
  495.     {
  496.         return FALSE;
  497.     }
  498.     for (j = 0; j < 5; j++)
  499.     {
  500.         *(arr+j) = *(pResource_info[i].filename_ext+j);
  501.     }
  502.     return TRUE;
  503. }
  504. /* 070306 Alpha layer End */
  505. /*****************************************************************************
  506.  * FUNCTION
  507.  *  isEmsImage
  508.  * DESCRIPTION
  509.  *  Decide if the iamge is used for EMS picture
  510.  *  
  511.  *  use EMS_IMAGE_PATH (defined in CustDataRes.h) to decide if a EMS picture
  512.  * PARAMETERS
  513.  *  path        [IN]        -> string containing file name and path
  514.  * RETURNS
  515.  *  U8 --> 1: EMS picture, 0: Not EMS picture
  516.  *****************************************************************************/
  517. U8 isEmsImage(S8 *path)
  518. {
  519.     /*----------------------------------------------------------------*/
  520.     /* Local Variables                                                */
  521.     /*----------------------------------------------------------------*/
  522.     S8 ems_path[] = EMS_IMAGE_PATH;
  523.     U8 pos = 0, ems_len = 0, i = 0;
  524.     /*----------------------------------------------------------------*/
  525.     /* Code Body                                                      */
  526.     /*----------------------------------------------------------------*/
  527.     ems_len = strlen(ems_path);
  528.     pos = strlen(path) - 1;
  529.     while (path[pos] != '\')
  530.     {
  531.         /* __CUSTPACK_MULTIBIN Calvin BEGIN */
  532.         if (pos == 0)   /* 040805 CustPack: Calvin added */
  533.         {
  534.             return 0;
  535.         }
  536.         /* __CUSTPACK_MULTIBIN Calvin END */
  537.         pos--;
  538.     }
  539.     pos -= ems_len + 1;
  540.     for (i = 0; i < ems_len; i++)
  541.     {
  542.         if (ems_path[i] != path[pos])
  543.         {
  544.             return 0;
  545.         }
  546.         else
  547.         {
  548.             pos++;
  549.         }
  550.     }
  551.     return 1;
  552. }
  553. /*****************************************************************************
  554.  * FUNCTION
  555.  *  isMainmenuImage
  556.  * DESCRIPTION
  557.  *  Decide if the iamge is used for Mainmenu picture
  558.  * PARAMETERS
  559.  *  path        [IN]        -> string containing file name and path
  560.  * RETURNS
  561.  *  U8 --> 1: Matrix Mainmenu picture, 0: Not Matrix mainmenu picture
  562.  *****************************************************************************/
  563. MMI_BOOL isMainmenuImage(S8 *path)
  564. {
  565.     /*----------------------------------------------------------------*/
  566.     /* Local Variables                                                */
  567.     /*----------------------------------------------------------------*/
  568.     /*----------------------------------------------------------------*/
  569.     /* Code Body                                                      */
  570.     /*----------------------------------------------------------------*/
  571.     if ((strstr(path, "\MATRIX\") != NULL) && (strstr(path, ".GIF") != NULL))
  572.     {
  573.         return MMI_TRUE;
  574.     }
  575.     else
  576.     {
  577.         return MMI_FALSE;
  578.     }
  579. }
  580. /*****************************************************************************
  581.  * FUNCTION
  582.  *  isSubmenuImage
  583.  * DESCRIPTION
  584.  *  Decide if the iamge is used for Submenu picture
  585.  *  
  586.  *  use SUBMENU_IMAGE_PATH (defined in CustDataRes.h) to decide if a EMS picture
  587.  * PARAMETERS
  588.  *  path        [IN]        -> string containing file name and path
  589.  * RETURNS
  590.  *  U8 --> 1: Submenu picture, 0: Not Submenu picture
  591.  *****************************************************************************/
  592. U8 isSubmenuImage(S8 *path)
  593. {
  594. #ifndef __MMI_SLIM_LISTMENU_NUMBER__
  595.     /*----------------------------------------------------------------*/
  596.     /* Local Variables                                                */
  597.     /*----------------------------------------------------------------*/
  598.     /*----------------------------------------------------------------*/
  599.     /* Code Body                                                      */
  600.     /*----------------------------------------------------------------*/
  601.     return 0;
  602. #else /* __MMI_SLIM_LISTMENU_NUMBER__ */ 
  603.     S8 submenu_path[] = SUBMENU_IMAGE_PATH;
  604.     U8 pos = 0, submenu_len = 0, i = 0;
  605.     if (strstr(path, submenu_path) != NULL)
  606.     {
  607.         return 1;
  608.     }
  609.     else
  610.     {
  611.         return 0;
  612.     }
  613.     /*
  614.      * submenu_len = strlen(submenu_path);
  615.      * pos = strlen (path)-1;
  616.      * while (path[pos]!='\') pos--;
  617.      * pos-=submenu_len+1;
  618.      * for ( i=0; i<submenu_len; i++){
  619.      * if ( submenu_path[i] != path[pos] ) return 0;
  620.      * else pos++;
  621.      * }
  622.      * return 1;
  623.      */
  624. #endif /* __MMI_SLIM_LISTMENU_NUMBER__ */ 
  625. }
  626. /* __CUSTPACK_MULTIBIN Calvin BEGIN */
  627. /* 040805 CustPack: Calvin added */
  628. /*****************************************************************************
  629.  * FUNCTION
  630.  *  ToUpper
  631.  * DESCRIPTION
  632.  *  
  633.  * PARAMETERS
  634.  *  ch      [IN]        
  635.  * RETURNS
  636.  *  
  637.  *****************************************************************************/
  638. S8 ToUpper(S8 ch)
  639. {
  640.     /*----------------------------------------------------------------*/
  641.     /* Local Variables                                                */
  642.     /*----------------------------------------------------------------*/
  643.     /*----------------------------------------------------------------*/
  644.     /* Code Body                                                      */
  645.     /*----------------------------------------------------------------*/
  646.     return toupper(ch);
  647. }
  648. /* Calvin end */
  649. /* __CUSTPACK_MULTIBIN Calvin END */
  650. /*****************************************************************************
  651.  * FUNCTION
  652.  *  Iload
  653.  * DESCRIPTION
  654.  *  Load the file image to buffer and writes to CustImgRes.c
  655.  * PARAMETERS
  656.  *  string      [IN]        -> string containing file name and path
  657.  *  pType       [OUT]       -> Image Type
  658.  * RETURNS
  659.  *  void* --> buffer containing image data
  660.  *****************************************************************************/
  661. MMI_BOOL Iload(S8 *string, PU16 pType)
  662. {
  663.     /*----------------------------------------------------------------*/
  664.     /* Local Variables                                                */
  665.     /*----------------------------------------------------------------*/
  666.     U32 image_counter = 0;
  667.     U32 image_offset = 0;
  668.     U32 failure_counter = 0;
  669.     U8 *pBuffer = NULL;
  670.     S32 j, sequence_counter, n_frames;
  671.     MMI_BOOL failure_flag;
  672.     U8 image_identifier;
  673.     S32 n_images = 0;
  674.     S32 file_size1 = 0;
  675.     S32 file_size = 0;
  676.     S32 nImageSize = 0;
  677.     U8 *pBuffer1 = NULL;
  678.     S32 extension_type = -1;
  679.     U8 staticFlag = 1;  /* Non animated image */
  680.     /* 070306 Alpha layer Start */
  681.     //#ifdef __MMI_ALPHA_LAYER_SUPPORT__
  682.     S32 ext_type = -1;
  683.     //#endif
  684.     /* 070306 Alpha layer End */
  685.     // __CUSTPACK_MULTIBIN Calvin BEGIN
  686.     //S8         tempDestFile[] = {"..\\..\\Customer\\IMAGES\TEMPIMAGE"};
  687.     S8 tempDestFile[] = { "TEMPIMAGE" };    /* 040805 CustPack: Calvin modified */
  688.     int ret = 1;
  689.     /* __CUSTPACK_MULTIBIN Calvin END */
  690.     S8 tempCommand[200];
  691.     size_t size;
  692.     U32 o = 0;
  693.     S16 filenameLen;
  694.     char *curr_output_data_filename;
  695. #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  696.     U32 enfb_width, enfb_height;//100206 ENFB support
  697.     S32 enfb_ret;
  698. #endif
  699.     /*----------------------------------------------------------------*/
  700.     /* Code Body                                                      */
  701.     /*----------------------------------------------------------------*/
  702.     g_ressize = 0;
  703.     if (ExtImageFlag == EXT_IMAGE)
  704.     {
  705.         curr_output_data_filename = OUTPUT_DATA_FILENAME_EXT;
  706.     }
  707.     else if (ExtImageFlag == SYSTEM_IMAGE)
  708.     {
  709.         curr_output_data_filename = OUTPUT_DATA_FILENAME;
  710.     }
  711.     else
  712.     {
  713.         curr_output_data_filename = NFB_IMAGE_DATA_FILENAME;
  714.         nfb_img_res_file = fopen(NFB_IMAGE_RES_FILENAME, "ab");
  715.     }
  716.     if (toolFlag == 1)
  717.     {   /* 040805 CustPack: Calvin added */
  718.         curr_output_data_filename = "temp";
  719.     }
  720.     strcpy(filename_buffer, curr_output_data_filename); /* 040805 CustPack: Calvin modified */
  721.     /* __CUSTPACK_MULTIBIN Calvin END */
  722.     output_data_file = fopen(filename_buffer, "ab");
  723.     while (!output_data_file)
  724.     {
  725.         Sleep(50);
  726.         output_data_file = fopen(filename_buffer, "ab");
  727.     }
  728.     //Move behind
  729.     //fprintf(output_data_file,"const U8 ");
  730.     output_image_names = (S8*) malloc(100);
  731.     strcpy(filename_buffer, string);
  732.     if (!(strcmp(filename_buffer, "")))
  733.     {
  734.         strcpy(filename_buffer, NOIMAGE_FILENAMEBUFFER);
  735.     }
  736.     Extract_Name(output_image_names, filename_buffer, RES_IMAGE);
  737. #ifdef __MMI_SLIM_LISTMENU_NUMBER__
  738.     if (isSubmenuImage(filename_buffer))
  739.     {
  740.         int i, len;
  741.         len = strlen(filename_buffer);
  742.         for (i = len; i > 0; i--)
  743.         {
  744.             if (filename_buffer[i] == 'U' && filename_buffer[i - 1] == 'N' && filename_buffer[i - 2] == 'E' &&
  745.                 filename_buffer[i - 3] == 'M' && filename_buffer[i - 4] == 'B' && filename_buffer[i - 5] == 'U' &&
  746.                 filename_buffer[i - 6] == 'S')
  747.             {
  748.                 filename_buffer[i + 1] = '2';
  749.                 break;
  750.             }
  751.             else
  752.             {
  753.                 filename_buffer[i + 1] = filename_buffer[i];
  754.             }
  755.         }
  756.         filename_buffer[len + 1] = '';
  757.     }
  758. #endif /* __MMI_SLIM_LISTMENU_NUMBER__ */ 
  759.     failure_flag = MMI_TRUE;
  760.     extension_type = -1;
  761.     sequence_counter = 0;
  762. /* 070306 Alpha layer Start */
  763. #ifdef __MMI_ALPHA_LAYER_SUPPORT__
  764.     //printf("inside 1n");
  765.     ext_type = ExtractExtension(filename_buffer, RES_IMAGE);
  766.     if (ext_type == IMAGE_TYPE_GIF || ext_type == IMAGE_TYPE_BMP)
  767.     {
  768.         //printf("inside GIF..BMP  %sn", filename_buffer);
  769.         ChangeExtension(filename_buffer, RES_IMAGE, IMAGE_TYPE_PNG);
  770.         //printf("out GIF..BMP  %sn", filename_buffer);
  771.     }
  772.     else if (ext_type == IMAGE_TYPE_DEVICE_BITMAP)
  773.     {
  774.         ChangeExtension(filename_buffer, RES_IMAGE, IMAGE_TYPE_PPN);
  775.     }
  776.     image_data_file = fopen(filename_buffer, "rb");
  777.     if (image_data_file == NULL)
  778.     {
  779.         ChangeExtension(filename_buffer, RES_IMAGE, ext_type);
  780.     }
  781.     else
  782.     {
  783.         fclose(image_data_file);
  784.     }
  785. #endif
  786.     ext_type = ExtractExtension(filename_buffer, RES_IMAGE);
  787.     if (ext_type == IMAGE_TYPE_PPN)
  788.     {
  789.         //ChangeExtension(filename_buffer, RES_IMAGE, IMAGE_TYPE_PNG);
  790.         strcpy((char*)tempBMPFile, (const char*)filename_buffer);
  791.         ChangeExtension(tempBMPFile, RES_IMAGE, IMAGE_TYPE_DEVICE_BITMAP);
  792.         sprintf(tempCommand,"convert.exe png:%s bmp:%s", filename_buffer, tempBMPFile);
  793.         //sprintf(tempCommand,"convert.exe png:%s bmp:%s", filename_buffer, "4.pbm");
  794.         //printf("%sn",tempCommand);
  795.         system(tempCommand);
  796.         strcpy((char*)filename_buffer, (const char*)tempBMPFile);
  797.         //printf("%sn",filename_buffer);
  798.     }
  799. /* 070306 Alpha layer End */
  800.     filenameLen = strlen(filename_buffer);
  801.     /* MTK Leo add, for EMS */
  802.     if (isEmsImage(filename_buffer))
  803.         /* if (filename_buffer[filenameLen-3] =='P' && filename_buffer[filenameLen-2] == 'I' && filename_buffer[filenameLen-1] =='C' ) */
  804.     {
  805.         image_data_file = fopen(filename_buffer, "rb");
  806.         if (image_data_file != NULL)
  807.         {
  808.             /* __CUSTPACK_MULTIBIN Calvin BEGIN */
  809.             if (toolFlag == 0)  /* 040805 CustPack: Calvin modified */
  810.             {
  811.                 fprintf(output_data_file, "const U8 ");
  812.                 fprintf(output_data_file, output_image_names);
  813.                 fprintf(output_data_file, "[]=");
  814.                 fclose(output_data_file);
  815.             }
  816.             //sprintf(tempCommand,"%s %s -b %s", EMSCONVERTER_FILENAME,filename_buffer,OUTPUT_DATA_FILENAME);//,output_image_names);
  817.             //system(tempCommand);
  818.             ret = bmp2ems(filename_buffer, curr_output_data_filename, 1, 0);    /* 040805 CustPack: Calvin modified */
  819.             if (toolFlag)
  820.             {
  821.                 if (ret == 0)//100206 ENFB support
  822.                 {
  823.                     resultFailFlag = 1;
  824.                 }
  825.             }
  826.             /* __CUSTPACK_MULTIBIN Calvin END */
  827.         }
  828.         else
  829.         {
  830.             /* fclose(image_data_file); */
  831.             failure_flag = MMI_FALSE;
  832.         }
  833.     }
  834.     else if ((filename_buffer[filenameLen - 1] == 'P' || filename_buffer[filenameLen - 1] == 'M') &&
  835.              (filename_buffer[filenameLen - 2] == 'R' || filename_buffer[filenameLen - 2] == 'B') &&
  836.              filename_buffer[filenameLen - 3] == 'P')
  837.     {
  838.         image_data_file = fopen(filename_buffer, "rb");
  839.         if (image_data_file != NULL)
  840.         {
  841.             if (filename_buffer[filenameLen - 2] == 'R')
  842.             {
  843.                 //sprintf(tempCommand,"%s %s %s", GIFCONVERTER_FILENAME,filename_buffer,tempDestFile);
  844.                 //system(tempCommand);//010505 Calvin moved
  845.                 GIFLoader(filename_buffer, tempDestFile);   /* 010505 Calvin added */
  846.             }
  847.             else
  848.             {
  849.                 //sprintf(tempCommand,"%s %s %s", BMPCONVERTER_FILENAME,filename_buffer,tempDestFile);
  850.                 //system(tempCommand);//010505 Calvin moved
  851.                 // __CUSTPACK_MULTIBIN Calvin BEGIN
  852.                 ret = BMPLoader(filename_buffer, tempDestFile); /* 010505 Calvin added */
  853.                 if (toolFlag)
  854.                 {
  855.                     if (ret = 0)
  856.                     {
  857.                         resultFailFlag = 1;
  858.                     }
  859.                 }
  860.                 /* __CUSTPACK_MULTIBIN Calvin END */
  861.             }
  862.             /* system(tempCommand);//010505 Calvin moved */
  863.             fclose(image_data_file);
  864.             /* __CUSTPACK_MULTIBIN Calvin BEGIN */
  865.             if (toolFlag == 0)  /* 040805 CustPack: Calvin modified */
  866.             {
  867.                 image_data_file = fopen(tempDestFile, "rb");
  868.                 if (image_data_file != NULL)
  869.                 {
  870.                     strcpy((char*)autoimagename_buffer, (const char*)output_image_names);
  871.                     strcat((char*)autoimagename_buffer, "[]=n");
  872.                     fprintf(output_data_file, "const U8 ");
  873.                     fprintf(output_data_file, autoimagename_buffer);
  874.                     if (ExtImageFlag == NFB_PROGRESS_IMAGE)
  875.                     {
  876.                         if (nfb_img_res_file != NULL)
  877.                         {
  878.                             fprintf(nfb_img_res_file, "(U8*)&%s,n", output_image_names);
  879.                             fclose(nfb_img_res_file);
  880.                         }
  881.                         else
  882.                         {
  883.                             printf("nfb_img_res_file not openedn");
  884.                         }
  885.                     }
  886.                     fseek(image_data_file, 0, SEEK_END);
  887.                     file_size = ftell(image_data_file);
  888.                     fseek(image_data_file, 0, SEEK_SET);
  889.                     while (!feof(image_data_file))
  890.                     {
  891.                         size = fread(tempCommand, sizeof(char), 200, image_data_file);
  892.                         if (size)
  893.                         {
  894.                             fwrite(tempCommand, sizeof(char), size, output_data_file);
  895.                         }
  896.                     }
  897.                     fputs("n", output_data_file);
  898.                 }
  899.             }
  900.             /* __CUSTPACK_MULTIBIN Calvin END */
  901.         }
  902.         else
  903.         {
  904.             failure_flag = MMI_FALSE;
  905.         }
  906.     }
  907.     else
  908.     {
  909.         image_data_file = fopen(filename_buffer, "rb");
  910.         /* MTK Leo add, for read images with same filename but different in ".bmp" and ".gif" */
  911.         if (image_data_file == NULL)
  912.         {
  913.             Sleep(50);
  914.             if (filename_buffer[filenameLen - 1] == 'P' && filename_buffer[filenameLen - 2] == 'M' &&
  915.                 filename_buffer[filenameLen - 3] == 'B')
  916.             {
  917.                 filename_buffer[filenameLen - 1] = 'F';
  918.                 filename_buffer[filenameLen - 2] = 'I';
  919.                 filename_buffer[filenameLen - 3] = 'G';
  920.             }
  921.             else if (isMainmenuImage(filename_buffer))
  922.             {
  923.                 filename_buffer[filenameLen - 1] = 'M';
  924.                 filename_buffer[filenameLen - 2] = 'B';
  925.                 filename_buffer[filenameLen - 3] = 'P';
  926.                 image_data_file = fopen(filename_buffer, "rb");
  927.                 if (image_data_file != NULL)
  928.                 {
  929.                     //sprintf(tempCommand,"%s %s %s", BMPCONVERTER_FILENAME,filename_buffer,tempDestFile);
  930.                     //system(tempCommand);
  931.                     // __CUSTPACK_MULTIBIN Calvin BEGIN
  932.                     ret = BMPLoader(filename_buffer, tempDestFile);     /* 010505 Calvin added */
  933.                     if (toolFlag)
  934.                     {
  935.                         if (ret = 0)
  936.                         {
  937.                             resultFailFlag = 1;
  938.                         }
  939.                     }
  940.                     /* __CUSTPACK_MULTIBIN Calvin END */
  941.                     /* __CUSTPACK_MULTIBIN Calvin BEGIN */
  942.                     if (toolFlag == 0)  /* 040805 CustPack: Calvin modified */
  943.                     {
  944.                         image_data_file = fopen(tempDestFile, "rb");
  945.                         if (image_data_file != NULL)
  946.                         {
  947.                             strcpy((char*)autoimagename_buffer, (const char*)output_image_names);
  948.                             strcat((char*)autoimagename_buffer, "[]=n");
  949.                             fprintf(output_data_file, "const U8 ");
  950.                             fprintf(output_data_file, autoimagename_buffer);
  951.                             if (ExtImageFlag == NFB_PROGRESS_IMAGE)
  952.                             {
  953.                                 if (nfb_img_res_file != NULL)
  954.                                 {
  955.                                     fprintf(nfb_img_res_file, "(U8*)&%s,n", output_image_names);
  956.                                     fclose(nfb_img_res_file);
  957.                                 }
  958.                                 else
  959.                                 {
  960.                                     printf("nfb_img_res_file not openedn");
  961.                                 }
  962.                             }
  963.                             fseek(image_data_file, 0, SEEK_END);
  964.                             file_size = ftell(image_data_file);
  965.                             fseek(image_data_file, 0, SEEK_SET);
  966.                             while (!feof(image_data_file))
  967.                             {
  968.                                 size = fread(tempCommand, sizeof(char), 200, image_data_file);
  969.                                 if (size)
  970.                                 {
  971.                                     fwrite(tempCommand, sizeof(char), size, output_data_file);
  972.                                 }
  973.                             }
  974.                             fputs("n", output_data_file);
  975.                         }
  976.                         fclose(image_data_file);
  977.                     }
  978.                     fclose(output_data_file);
  979.                     return MMI_TRUE;
  980.                     /* __CUSTPACK_MULTIBIN Calvin END */
  981.                 }
  982.             }
  983.             else if (filename_buffer[filenameLen - 1] == 'F' && filename_buffer[filenameLen - 2] == 'I' &&
  984.                      filename_buffer[filenameLen - 3] == 'G')
  985.             {
  986.                 filename_buffer[filenameLen - 1] = 'P';
  987.                 filename_buffer[filenameLen - 2] = 'M';
  988.                 filename_buffer[filenameLen - 3] = 'B';
  989.             }
  990.             image_data_file = fopen(filename_buffer, "rb");
  991.         }
  992.         /* MTK Leo end */
  993.         if (image_data_file == NULL)
  994.         {
  995.             /* Add extension add search */
  996.             FILE *fail = fopen("fail.txt", "a+");
  997.             if (fail != NULL)
  998.             {
  999.                 /* __CUSTPACK_MULTIBIN Calvin BEGIN */
  1000.                 if (toolFlag == 0)  /* 040805 CustPack: Calvin modified */
  1001.                 {
  1002.                     fprintf(fail, "%sn", filename_buffer);
  1003.                     fclose(fail);
  1004.                 }
  1005.                 failure_flag = MMI_FALSE;   /* 021705 Calvin moved from down */
  1006.                 /* __CUSTPACK_MULTIBIN Calvin END */
  1007.             }
  1008.         /* 070306 Alpha layer Start */
  1009.         /* Find the right extension file name */
  1010.         #ifdef __MMI_ALPHA_LAYER_SUPPORT__
  1011.             for (j = SUPPORT_N_SEQUENTIAL_IMAGE_TYPE-1; j >= 0; j--)//search from PNG       
  1012.         #else
  1013.             for (j = 0; j < SUPPORT_N_SEQUENTIAL_IMAGE_TYPE; j++)//search from BMP       
  1014.         #endif
  1015.         /* 070306 Alpha layer End */
  1016.             {
  1017.                 itoa(0, number_string, 10);
  1018.                 extension_type = -1;
  1019.                 strcpy(autofilename_buffer, filename_buffer);
  1020.                 strcat(autofilename_buffer, "\\");
  1021.                 /* strcat(autofilename_buffer,output_image_names); */
  1022.                 strcat(autofilename_buffer, number_string);
  1023.                 strcat(autofilename_buffer, ".");
  1024.                 strcat(autofilename_buffer, sequential_image[j].filename_ext);
  1025.                 image_data_file = fopen(autofilename_buffer, "rb");
  1026.                 if (image_data_file != NULL)
  1027.                 {
  1028.                     failure_flag = MMI_TRUE;
  1029.                     extension_type = sequential_image[j].file_type;
  1030.                     staticFlag = 0;
  1031.                     *pType = (U16) extension_type;
  1032.                     sequential_extension_type = j;  /* 031705 Calvin modified */
  1033.                     fclose(image_data_file);
  1034.                     break;
  1035.                 }
  1036.             }
  1037.             // __CUSTPACK_MULTIBIN Calvin BEGIN    
  1038.             //failure_flag = MMI_FALSE;//021705 Calvin moved to up
  1039.             // __CUSTPACK_MULTIBIN Calvin END
  1040.         }
  1041.         else
  1042.         {
  1043.             /* patch added by vikram for getting image file size */
  1044.             fseek(image_data_file, 0, SEEK_END);
  1045.             nImageSize = ftell(image_data_file);
  1046.             fseek(image_data_file, 0, SEEK_SET);
  1047.         }
  1048.         if ((failure_flag == MMI_TRUE) && !(staticFlag))
  1049.         {
  1050.             /* Sequence found */
  1051.             /* Find how many files are in sequence */
  1052.             j = 0;
  1053.             sequence_counter = 0;
  1054.             n_frames = 0;
  1055.             while (1)
  1056.             {
  1057.                 itoa(j, number_string, 10);
  1058.                 strcpy(autofilename_buffer, "");
  1059.                 strcpy(autofilename_buffer, filename_buffer);
  1060.                 strcat(autofilename_buffer, "\\");
  1061.                 /* strcat(autofilename_buffer,output_image_names); */
  1062.                 strcat(autofilename_buffer, number_string);
  1063.                 strcat(autofilename_buffer, ".");
  1064.                 strcat(autofilename_buffer, sequential_image[sequential_extension_type].filename_ext);  /* 031705 Calvin modified */
  1065.                 image_data_file = fopen(autofilename_buffer, "rb");
  1066.                 if (image_data_file != NULL)
  1067.                 {
  1068.                     sequence_counter++;
  1069.                     fseek(image_data_file, 0, SEEK_END);
  1070.                     sequential_filesize[j] = ftell(image_data_file);
  1071.                     fseek(image_data_file, 0, SEEK_SET);
  1072.                     fclose(image_data_file);
  1073.                 }
  1074.                 else
  1075.                 {   /*   Sequence complete */
  1076.                     if (j > 0)
  1077.                     {
  1078.                         break;
  1079.                     }
  1080.                 }
  1081.                 j++;
  1082.             }
  1083.             /* read during */
  1084.             {
  1085.                 int i;
  1086.                 strcpy(autofilename_buffer, filename_buffer);
  1087.                 strcat(autofilename_buffer, "\\interval.txt");
  1088.                 /* 070306 interval missing Start */
  1089.                 image_data_file = NULL;
  1090.                 image_data_file = fopen(autofilename_buffer, "r");
  1091.                 if (image_data_file == NULL)
  1092.                 {
  1093.                     printf("ERROR: Can't find %sn", autofilename_buffer);
  1094.                     staticFlag = 1;
  1095.                     failure_flag = MMI_FALSE;
  1096.                 }
  1097.                 else
  1098.                 {
  1099.                     for (i = 0; i < sequence_counter; i++)
  1100.                     {
  1101.                         if (fscanf(image_data_file, "%d", &sequential_interval[i]) != 1)
  1102.                         {
  1103.                             printf("ERROR: %s, interval [%d] value missing!!n", autofilename_buffer, i);
  1104.                             staticFlag = 1;
  1105.                             failure_flag = MMI_FALSE;
  1106.                             break;
  1107.                         }
  1108.                     }
  1109.                 }
  1110.                 if (image_data_file != NULL)
  1111.                 {
  1112.                     fclose(image_data_file);
  1113.                 }
  1114.                 /* 070306 interval missing End */
  1115.             }
  1116.             /* 070306 interval missing Start */
  1117.             if(!staticFlag)
  1118.             {               
  1119.             /* 100206 ENFB support Start */
  1120.             #ifdef __MMI_RESOURCE_ENFB_SUPPORT__                
  1121.                 itoa(0, number_string, 10);
  1122.                 strcpy(autofilename_buffer, "");
  1123.                 strcpy(autofilename_buffer, filename_buffer);
  1124.                 strcat(autofilename_buffer, "\\");
  1125.                 strcat(autofilename_buffer, number_string);
  1126.                 strcat(autofilename_buffer, ".");
  1127.                 strcat(autofilename_buffer, sequential_image[sequential_extension_type].filename_ext);  /* 031705 Calvin modified */
  1128.                 enfb_ret = Image_Test(autofilename_buffer, &enfb_width, &enfb_height);
  1129.                 if (enfb_ret!= ENFB_IMAGE_NONE)
  1130.                 {
  1131.                     enfbFlag = 1;
  1132.                     if (enfb_ret == ENFB_IMAGE_ASSOCIATE)
  1133.                     {
  1134.                         ENFBAssociatedIDAdded = MMI_TRUE;
  1135.                     }
  1136.                 }
  1137.                 //printf("sequential %s --> %d x %dn", autofilename_buffer, enfb_width, enfb_height);
  1138.             #endif
  1139.             /* 100206 ENFB support Start */
  1140.             
  1141.                 /* n_frames=sequence_counter; */
  1142.                 sequential_frame = sequence_counter;
  1143.                 /* Construct the data structure name  */
  1144.                 strcpy(autoimagename_buffer, output_image_names);
  1145.                 strcat(autoimagename_buffer, OUTPUT_IMAGE_NAMES_END);
  1146.                 fprintf(output_data_file, "__align(4) const U8 ");
  1147.                 fprintf(output_data_file, autoimagename_buffer);
  1148.                 Write_Sequential_Image_Header(output_data_file, sequential_image[sequential_extension_type].file_type, sequential_frame, sequential_filesize, sequential_offset);   /* 031705 Calvin modified */
  1149.                 /* Load all files in the sequence   */
  1150.                 j = 0;
  1151.                 sequence_counter = 0;
  1152.                 while (1)
  1153.                 {
  1154.                     itoa(j, number_string, 10);
  1155.                     strcpy(autofilename_buffer, "");
  1156.                     strcpy(autofilename_buffer, filename_buffer);
  1157.                     strcat(autofilename_buffer, "\\");
  1158.                     /* strcat(autofilename_buffer,output_image_names); */
  1159.                     strcat(autofilename_buffer, number_string);
  1160.                     strcat(autofilename_buffer, ".");
  1161.                     strcat(autofilename_buffer, sequential_image[sequential_extension_type].filename_ext);  /* 031705 Calvin modified */
  1162.                     image_data_file = fopen(autofilename_buffer, "rb");
  1163.                     if (image_data_file != NULL)
  1164.                     {
  1165.                         Write_Sequential_Image_File(output_data_file, image_data_file, sequential_filesize[j]);
  1166.                         sequence_counter++;
  1167.                         fclose(image_data_file);
  1168.                     }
  1169.                     else
  1170.                     {   /*   Sequence complete */
  1171.                         if (j > 0)
  1172.                         {
  1173.                             break;
  1174.                         }
  1175.                     }
  1176.                     j++;
  1177.                 }
  1178.                 fprintf(output_data_file, "n};n");
  1179.             /* 100206 ENFB support Start */
  1180.             #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  1181.                 enfbFlag = 0;
  1182.             #endif
  1183.             /* 100206 ENFB support Start */
  1184.             }
  1185.             /* 070306 interval missing End */
  1186.         }   /* End of Animated image processor block */
  1187.         if ((failure_flag == MMI_TRUE) && (staticFlag))
  1188.         {
  1189.             /* Currently assuming that all single files are BMP   */
  1190.             if (nImageSize == 0)
  1191.             {
  1192.                 image_identifier = IMAGE_TYPE_INVALID;  /* 031705 Calvin modified */
  1193.             }
  1194.             else
  1195.             {
  1196.                 /* MTK Leo add, for read images with same filename but different in ".bmp" and ".gif" */
  1197.                 image_identifier = ExtractExtension(filename_buffer, RES_IMAGE);        /* 101205 audio resource Calvin */
  1198.             }
  1199.             /* To be changed later for multiple file types */
  1200.             *pType = ExtractExtension(filename_buffer, RES_IMAGE);      /* 101205 audio resource Calvin */
  1201.             /* MTK Leo end */
  1202.             /*   Load the data  */
  1203.             /* Construct the data structure name */
  1204.             strcpy(autoimagename_buffer, output_image_names);
  1205.             strcat(autoimagename_buffer, OUTPUT_IMAGE_NAMES_END);
  1206.             if (image_identifier == IMAGE_TYPE_GIF || image_identifier == IMAGE_TYPE_3GP ||
  1207.                 image_identifier == IMAGE_TYPE_MP4 || image_identifier == IMAGE_TYPE_AVI ||
  1208.                 image_identifier == IMAGE_TYPE_PNG || image_identifier == IMAGE_TYPE_M3D ||
  1209.                 image_identifier == IMAGE_TYPE_SWFLASH)
  1210.             {
  1211.                 fprintf(output_data_file, "__align(4) const U8 ");
  1212.             }
  1213.             else
  1214.             {
  1215.                 fprintf(output_data_file, "const U8 ");
  1216.             }
  1217.             fprintf(output_data_file, autoimagename_buffer);
  1218.             fseek(image_data_file, 0, SEEK_END);
  1219.             if (image_identifier == IMAGE_TYPE_GIF || image_identifier == IMAGE_TYPE_3GP ||
  1220.                 image_identifier == IMAGE_TYPE_MP4 || image_identifier == IMAGE_TYPE_AVI ||
  1221.                 image_identifier == IMAGE_TYPE_PNG || image_identifier == IMAGE_TYPE_M3D ||
  1222.                 image_identifier == IMAGE_TYPE_SWFLASH)
  1223.             {
  1224.                 file_size1 = file_size1 + ftell(image_data_file) + 8;
  1225.             }
  1226.             else
  1227.             {
  1228.                 file_size1 = file_size1 + ftell(image_data_file) + 6;
  1229.             }
  1230.             fseek(image_data_file, 0, SEEK_SET);
  1231.             pBuffer = (U8*) malloc(file_size1);
  1232.             if (pBuffer == NULL)
  1233.             {
  1234.                 /* Add Debug Message */
  1235.             }
  1236.             pBuffer1 = pBuffer;
  1237.         /* 100206 ENFB support Start */
  1238.         #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  1239.             enfb_ret = Image_Test(filename_buffer, &enfb_width, &enfb_height);
  1240.             if (enfb_ret != ENFB_IMAGE_NONE)
  1241.             {
  1242.                 enfbFlag = 1;
  1243.                 if (enfb_ret == ENFB_IMAGE_ASSOCIATE)
  1244.                 {
  1245.                     ENFBAssociatedIDAdded = MMI_TRUE;
  1246.                 }
  1247.             }
  1248.         #endif
  1249.         /* 100206 ENFB support End */
  1250.             g_ressize = Load_Image_Data(&image_offset, output_data_file, image_data_file, pBuffer1, image_identifier, 0);
  1251.         /* 100206 ENFB support Start */
  1252.         #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  1253.             enfbFlag = 0;
  1254.         #endif
  1255.         /* 100206 ENFB support Start */
  1256.             //printf("load_image_datan");//070306 Alpha layer
  1257.             if (ExtImageFlag == NFB_PROGRESS_IMAGE)
  1258.             {
  1259.                 printf("NFB_PROGRESS_IMAGEn");
  1260.                 if (nfb_img_res_file != NULL)
  1261.                 {
  1262.                     printf("nfb_img_res_filen");
  1263.                     fprintf(nfb_img_res_file, "(U8*)&%s,n", output_image_names);
  1264.                     fclose(nfb_img_res_file);
  1265.                 }
  1266.                 else
  1267.                 {
  1268.                     printf("nfb_img_res_file not openedn");
  1269.                 }
  1270.             }
  1271.             free(pBuffer);
  1272.             fprintf(output_data_file, "n };n");
  1273.             fclose(image_data_file);
  1274.         }
  1275.     }
  1276.     /* 120704 Calvin added for populating with .bmp or .gif but actually extsion name is not */
  1277.     if (failure_flag == MMI_FALSE)
  1278.     {
  1279.         /* printf("*************failed !!!********************n"); */
  1280.         for (j = 0; j < SUPPORT_N_MEDIA_TYPE; j++)
  1281.         {
  1282.             S32 l;
  1283.             for (l = 0; l < 3; l++)
  1284.             {
  1285.                 filename_buffer[filenameLen - 1 - l] = support_media_ext[j][2 - l];
  1286.             }
  1287.             /* printf("%s__%sn", support_media_ext[j], filename_buffer); */
  1288.             image_data_file = fopen(filename_buffer, "rb");
  1289.             if (image_data_file != NULL)
  1290.             {
  1291.                 break;
  1292.             }
  1293.         }
  1294.         if (image_data_file != NULL)
  1295.         {
  1296.             failure_flag = MMI_TRUE;
  1297.             /* printf("got %s n", filename_buffer); */
  1298.             fseek(image_data_file, 0, SEEK_END);
  1299.             nImageSize = ftell(image_data_file);
  1300.             fseek(image_data_file, 0, SEEK_SET);
  1301.             /* Currently assuming that all single files are BMP   */
  1302.             if (nImageSize == 0)
  1303.             {
  1304.                 image_identifier = IMAGE_TYPE_INVALID;  /* 031705 Calvin modified */
  1305.             }
  1306.             else
  1307.             {
  1308.                 /* MTK Leo add, for read images with same filename but different in ".bmp" and ".gif" */
  1309.                 image_identifier = ExtractExtension(filename_buffer, RES_IMAGE);        /* 101205 audio resource Calvin */
  1310.             }
  1311.             /* To be changed later for multiple file types */
  1312.             *pType = ExtractExtension(filename_buffer, RES_IMAGE);      /* 101205 audio resource Calvin */
  1313.             /* MTK Leo end */
  1314.             /*   Load the data  */
  1315.             /* Construct the data structure name */
  1316.             strcpy(autoimagename_buffer, output_image_names);
  1317.             strcat(autoimagename_buffer, OUTPUT_IMAGE_NAMES_END);
  1318.             if (image_identifier == IMAGE_TYPE_GIF || image_identifier == IMAGE_TYPE_3GP ||
  1319.                 image_identifier == IMAGE_TYPE_MP4 || image_identifier == IMAGE_TYPE_AVI ||
  1320.                 image_identifier == IMAGE_TYPE_PNG || image_identifier == IMAGE_TYPE_M3D ||
  1321.                 image_identifier == IMAGE_TYPE_SWFLASH)
  1322.             {
  1323.                 fprintf(output_data_file, "__align(4) const U8 ");
  1324.             }
  1325.             else
  1326.             {
  1327.                 fprintf(output_data_file, "const U8 ");
  1328.             }
  1329.             fprintf(output_data_file, autoimagename_buffer);
  1330.             fseek(image_data_file, 0, SEEK_END);
  1331.             if (image_identifier == IMAGE_TYPE_GIF || image_identifier == IMAGE_TYPE_3GP ||
  1332.                 image_identifier == IMAGE_TYPE_MP4 || image_identifier == IMAGE_TYPE_AVI ||
  1333.                 image_identifier == IMAGE_TYPE_PNG || image_identifier == IMAGE_TYPE_M3D ||
  1334.                 image_identifier == IMAGE_TYPE_SWFLASH)
  1335.             {
  1336.                 file_size1 = file_size1 + ftell(image_data_file) + 8;
  1337.             }
  1338.             else
  1339.             {
  1340.                 file_size1 = file_size1 + ftell(image_data_file) + 6;
  1341.             }
  1342.             fseek(image_data_file, 0, SEEK_SET);
  1343.             pBuffer = (U8*) malloc(file_size1);
  1344.             if (pBuffer == NULL)
  1345.             {
  1346.                 /* Add Debug Message */
  1347.             }
  1348.             pBuffer1 = pBuffer;
  1349.         /* 100206 ENFB support Start */
  1350.         #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  1351.             enfb_ret = Image_Test(filename_buffer, &enfb_width, &enfb_height);
  1352.             if (enfb_ret != ENFB_IMAGE_NONE)
  1353.             {
  1354.                 enfbFlag = 1;
  1355.                 if (enfb_ret == ENFB_IMAGE_ASSOCIATE)
  1356.                 {
  1357.                     ENFBAssociatedIDAdded = MMI_TRUE;
  1358.                 }
  1359.             }
  1360.         #endif
  1361.         /* 100206 ENFB support End */
  1362.         
  1363.             g_ressize = Load_Image_Data(&image_offset, output_data_file, image_data_file, pBuffer1, image_identifier, 0);
  1364.    
  1365.         /* 100206 ENFB support Start */
  1366.         #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  1367.             enfbFlag = 0;
  1368.         #endif
  1369.         /* 100206 ENFB support End */
  1370.         
  1371.             //printf("load_image_datan");//070306 Alpha layer
  1372.             if (ExtImageFlag == NFB_PROGRESS_IMAGE)
  1373.             {
  1374.                 printf("NFB_PROGRESS_IMAGEn");
  1375.                 if (nfb_img_res_file != NULL)
  1376.                 {
  1377.                     printf("nfb_img_res_filen");
  1378.                     fprintf(nfb_img_res_file, "(U8*)&%s,n", output_image_names);
  1379.                     fclose(nfb_img_res_file);
  1380.                 }
  1381.                 else
  1382.                 {
  1383.                     printf("nfb_img_res_file not openedn");
  1384.                 }
  1385.             }
  1386.             free(pBuffer);
  1387.             fprintf(output_data_file, "n };n");
  1388.             fclose(image_data_file);
  1389.         }
  1390.     }
  1391.     /* Calvin end */
  1392.     if (image_data_file != NULL)
  1393.     {
  1394.         fclose(image_data_file);
  1395.     }
  1396.     if (output_data_file != NULL)
  1397.     {
  1398.         fclose(output_data_file);
  1399.     }
  1400.     return failure_flag;
  1401. }
  1402. /* 101205 audio resource Calvin Satrt */
  1403. /*****************************************************************************
  1404.  * FUNCTION
  1405.  *  Aload
  1406.  * DESCRIPTION
  1407.  *  Load the file audio to buffer and writes to CustAdoRes.c
  1408.  * PARAMETERS
  1409.  *  string      [IN]        -> string containing file name and path
  1410.  *  pType       [OUT]       -> Audio Type
  1411.  * RETURNS
  1412.  *  void* --> buffer containing Audio data
  1413.  *****************************************************************************/
  1414. MMI_BOOL Aload(S8 *string, PU16 pType)
  1415. {
  1416.     /*----------------------------------------------------------------*/
  1417.     /* Local Variables                                                */
  1418.     /*----------------------------------------------------------------*/
  1419.     U32 audio_offset = 0;
  1420.     U8 *pBuffer = NULL;
  1421.     S32 j, n_frames;
  1422.     MMI_BOOL failure_flag;
  1423.     U8 audio_identifier;
  1424.     S32 file_size1 = 0;
  1425.     S32 file_size = 0;
  1426.     S32 nAudioSize = 0;
  1427.     U8 *pBuffer1 = NULL;
  1428.     U8 staticFlag = 1;  /* Non animated audio */
  1429.     /* S8           tempDestFile[] = {"TEMPAUDIO"}; */
  1430.     int ret = 1;
  1431.     /* S8           tempCommand[200]; */
  1432.     size_t size;
  1433.     U32 o = 0;
  1434.     S16 filenameLen;
  1435.     char *curr_output_data_filename;
  1436.     /*----------------------------------------------------------------*/
  1437.     /* Code Body                                                      */
  1438.     /*----------------------------------------------------------------*/
  1439.     g_ressize = 0;
  1440.     if (ExtAudioFlag == TRUE)   /* 040805 CustPack: Calvin added */
  1441.     {
  1442.         curr_output_data_filename = AUDIO_OUTPUT_DATA_FILENAME_EXT;
  1443.     }
  1444.     else
  1445.     {
  1446.         curr_output_data_filename = AUDIO_OUTPUT_DATA_FILENAME;
  1447.     }
  1448.     if (toolFlag == 1)
  1449.     {   /* 040805 CustPack: Calvin added */
  1450.         curr_output_data_filename = "temp";
  1451.     }
  1452.     strcpy(filename_buffer, curr_output_data_filename); /* 040805 CustPack: Calvin modified */
  1453.     output_data_file = fopen(filename_buffer, "ab");
  1454.     while (!output_data_file)
  1455.     {
  1456.         Sleep(50);
  1457.         output_data_file = fopen(filename_buffer, "ab");
  1458.     }
  1459.     output_audio_names = (S8*) malloc(100);
  1460.     strcpy(filename_buffer, string);
  1461.     if (!(strcmp(filename_buffer, "")))
  1462.     {
  1463.         strcpy(filename_buffer, NOAUDIO_FILENAMEBUFFER);
  1464.     }
  1465.     Extract_Name(output_audio_names, filename_buffer, RES_AUDIO);
  1466.     failure_flag = MMI_TRUE;
  1467.     filenameLen = strlen(filename_buffer);
  1468. #if 0
  1469. /* under construction !*/
  1470. /* under construction !*/
  1471. /* under construction !*/
  1472. /* under construction !*/
  1473. /* under construction !*/
  1474. /* under construction !*/
  1475. /* under construction !*/
  1476. /* under construction !*/
  1477. /* under construction !*/
  1478. /* under construction !*/
  1479. /* under construction !*/
  1480. /* under construction !*/
  1481. /* under construction !*/
  1482. /* under construction !*/
  1483. /* under construction !*/
  1484. /* under construction !*/
  1485. /* under construction !*/
  1486. /* under construction !*/
  1487. /* under construction !*/
  1488. /* under construction !*/
  1489. /* under construction !*/
  1490. /* under construction !*/
  1491. /* under construction !*/
  1492. /* under construction !*/
  1493. /* under construction !*/
  1494. /* under construction !*/
  1495. /* under construction !*/
  1496. /* under construction !*/
  1497. /* under construction !*/
  1498. /* under construction !*/
  1499. /* under construction !*/
  1500. /* under construction !*/
  1501. /* under construction !*/
  1502. /* under construction !*/
  1503. /* under construction !*/
  1504. /* under construction !*/
  1505. /* under construction !*/
  1506. /* under construction !*/
  1507. /* under construction !*/
  1508. /* under construction !*/
  1509. /* under construction !*/
  1510. /* under construction !*/
  1511. /* under construction !*/
  1512. /* under construction !*/
  1513. /* under construction !*/
  1514. /* under construction !*/
  1515. /* under construction !*/
  1516. /* under construction !*/
  1517. /* under construction !*/
  1518. /* under construction !*/
  1519. /* under construction !*/
  1520. /* under construction !*/
  1521. /* under construction !*/
  1522. /* under construction !*/
  1523. /* under construction !*/
  1524. /* under construction !*/
  1525. /* under construction !*/
  1526. /* under construction !*/
  1527. /* under construction !*/
  1528. /* under construction !*/
  1529. #endif /* 0 */ 
  1530.     {
  1531.         audio_data_file = fopen(filename_buffer, "rb");
  1532.         if (audio_data_file == NULL)
  1533.         {
  1534.             /* Add extension add search */
  1535.             FILE *fail = fopen("fail.txt", "a+");
  1536.             if (fail != NULL)
  1537.             {
  1538.                 if (toolFlag == 0)  /* 040805 CustPack: Calvin modified */
  1539.                 {
  1540.                     fprintf(fail, "%sn", filename_buffer);
  1541.                     fclose(fail);
  1542.                 }
  1543.                 failure_flag = MMI_FALSE;   /* 021705 Calvin moved from down */
  1544.             }
  1545.         }
  1546.         else
  1547.         {
  1548.             /* patch added by vikram for getting audio file size */
  1549.             fseek(audio_data_file, 0, SEEK_END);
  1550.             nAudioSize = ftell(audio_data_file);
  1551.             fseek(audio_data_file, 0, SEEK_SET);
  1552.         }
  1553.         if ((failure_flag == MMI_TRUE) && (staticFlag))
  1554.         {
  1555.             /* Currently assuming that all single files are BMP   */
  1556.             if (nAudioSize == 0)
  1557.             {
  1558.                 audio_identifier = AUDIO_TYPE_INVALID;  /* 031705 Calvin modified */
  1559.             }
  1560.             else
  1561.             {
  1562.                 /* MTK Leo add, for read audios with same filename but different in ".bmp" and ".gif" */
  1563.                 audio_identifier = ExtractExtension(filename_buffer, RES_AUDIO);        /* 101205 audio resource Calvin */
  1564.             }
  1565.             /* To be changed later for multiple file types */
  1566.             *pType = ExtractExtension(filename_buffer, RES_AUDIO);      /* 101205 audio resource Calvin */
  1567.             /*   Load the data  */
  1568.             /* Construct the data structure name */
  1569.             strcpy(autoimagename_buffer, output_audio_names);
  1570.             strcat(autoimagename_buffer, OUTPUT_AUDIO_NAMES_END);
  1571.             fprintf(output_data_file, "__align(4) const U8 ");
  1572.             fprintf(output_data_file, autoimagename_buffer);
  1573.             fseek(audio_data_file, 0, SEEK_END);
  1574.             file_size1 = file_size1 + ftell(audio_data_file) + 8;
  1575.             fseek(audio_data_file, 0, SEEK_SET);
  1576.             pBuffer = (U8*) malloc(file_size1);
  1577.             if (pBuffer == NULL)
  1578.             {
  1579.                 /* Add Debug Message */
  1580.             }
  1581.             pBuffer1 = pBuffer;
  1582.             g_ressize = Load_Audio_Data(&audio_offset, output_data_file, audio_data_file, pBuffer1, audio_identifier);
  1583.             free(pBuffer);
  1584.             fprintf(output_data_file, "n };n");
  1585.             fclose(audio_data_file);
  1586.         }
  1587.     }
  1588. #if 0
  1589. /* under construction !*/
  1590. /* under construction !*/
  1591. /* under construction !*/
  1592. /* under construction !*/
  1593. /* under construction !*/
  1594. /* under construction !*/
  1595. /* under construction !*/
  1596. /* under construction !*/
  1597. /* under construction !*/
  1598. /* under construction !*/
  1599. /* under construction !*/
  1600. /* under construction !*/
  1601. /* under construction !*/
  1602. /* under construction !*/
  1603. /* under construction !*/
  1604. /* under construction !*/
  1605. /* under construction !*/
  1606. /* under construction !*/
  1607. /* under construction !*/
  1608. /* under construction !*/
  1609. /* under construction !*/
  1610. /* under construction !*/
  1611. /* under construction !*/
  1612. /* under construction !*/
  1613. /* under construction !*/
  1614. /* under construction !*/
  1615. /* under construction !*/
  1616. /* under construction !*/
  1617. /* under construction !*/
  1618. /* under construction !*/
  1619. /* under construction !*/
  1620. /* under construction !*/
  1621. /* under construction !*/
  1622. /* under construction !*/
  1623. /* under construction !*/
  1624. /* under construction !*/
  1625. /* under construction !*/
  1626. /* under construction !*/
  1627. /* under construction !*/
  1628. /* under construction !*/
  1629. /* under construction !*/
  1630. /* under construction !*/
  1631. /* under construction !*/
  1632. /* under construction !*/
  1633. /* under construction !*/
  1634. /* under construction !*/
  1635. /* under construction !*/
  1636. /* under construction !*/
  1637. /* under construction !*/
  1638. /* under construction !*/
  1639. /* under construction !*/
  1640. /* under construction !*/
  1641. /* under construction !*/
  1642. /* under construction !*/
  1643. /* under construction !*/
  1644. /* under construction !*/
  1645. /* under construction !*/
  1646. /* under construction !*/
  1647. /* under construction !*/
  1648. /* under construction !*/
  1649. /* under construction !*/
  1650. /* under construction !*/
  1651. /* under construction !*/
  1652. /* under construction !*/
  1653. /* under construction !*/
  1654. /* under construction !*/
  1655. /* under construction !*/
  1656. /* under construction !*/
  1657. /* under construction !*/
  1658. /* under construction !*/
  1659. /* under construction !*/
  1660. /* under construction !*/
  1661. /* under construction !*/
  1662. /* under construction !*/
  1663. /* under construction !*/
  1664. /* under construction !*/
  1665. /* under construction !*/
  1666. /* under construction !*/
  1667. /* under construction !*/
  1668. /* under construction !*/
  1669. #endif /* 0 */ 
  1670.     if (audio_data_file != NULL)
  1671.     {
  1672.         fclose(audio_data_file);
  1673.     }
  1674.     if (output_data_file != NULL)
  1675.     {
  1676.         fclose(output_data_file);
  1677.     }
  1678.     return failure_flag;
  1679. }
  1680. /* 101205 audio resource Calvin End */
  1681. /*****************************************************************************
  1682.  * FUNCTION
  1683.  *  ClearHWIMageFile
  1684.  * DESCRIPTION
  1685.  *  Clear image file
  1686.  * PARAMETERS
  1687.  *  void
  1688.  * RETURNS
  1689.  *  void
  1690.  *****************************************************************************/
  1691. void ClearHWIMageFile()
  1692. {
  1693.     /*----------------------------------------------------------------*/
  1694.     /* Local Variables                                                */
  1695.     /*----------------------------------------------------------------*/
  1696.     FILE *fp;
  1697.     /*----------------------------------------------------------------*/
  1698.     /* Code Body                                                      */
  1699.     /*----------------------------------------------------------------*/
  1700.     fp = fopen(OUTPUT_DATA_FILENAME, "w+");
  1701.     if (fp)
  1702.     {
  1703.         fprintf(fp, "#if ( defined (MMI_ON_WIN32) || !defined (__MTK_TARGET__) )nt#define __align(x)n#endifn");
  1704.         fclose(fp);
  1705.     }
  1706.     /* __CUSTPACK_MULTIBIN Calvin BEGIN */
  1707.     fp = fopen(OUTPUT_DATA_FILENAME_EXT, "w+"); /* 040805 CustPack: Calvin added */
  1708.     /* __CUSTPACK_MULTIBIN Calvin END */
  1709.     if (fp)
  1710.     {
  1711.         fprintf(fp, "#if ( defined (MMI_ON_WIN32) || !defined (__MTK_TARGET__) )nt#define __align(x)n#endifn");
  1712.         fclose(fp);
  1713.     }
  1714.     /* 101205 audio resource Calvin Satrt */
  1715.     fp = fopen(AUDIO_OUTPUT_DATA_FILENAME, "w+");
  1716.     if (fp)
  1717.     {
  1718.         fprintf(fp, "#if ( defined (MMI_ON_WIN32) || !defined (__MTK_TARGET__) )nt#define __align(x)n#endifn");
  1719.         fclose(fp);
  1720.     }
  1721.     fp = fopen(AUDIO_OUTPUT_DATA_FILENAME_EXT, "w+");
  1722.     if (fp)
  1723.     {
  1724.         fprintf(fp, "#if ( defined (MMI_ON_WIN32) || !defined (__MTK_TARGET__) )nt#define __align(x)n#endifn");
  1725.         fclose(fp);
  1726.     }
  1727.     /* 101205 audio resource Calvin End */
  1728.     
  1729.     /* 100206 ENFB support Satrt */
  1730. #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  1731.     enfb_img_data_file = fopen(ENFB_IMAGE_DATA_FILENAME, "w+");
  1732.     if (enfb_img_data_file)
  1733.     {
  1734.         fclose(enfb_img_data_file);
  1735.     }
  1736.     enfb_img_data_file = fopen(ENFB_IMAGE_DATA_FILENAME, "ab");
  1737. #endif
  1738.     /* 100206 ENFB support End */
  1739. }
  1740. #endif /* DEVELOPER_BUILD_FIRST_PASS */ 
  1741. #if defined(CUSTOMIZATION_BUILD_FIRST_PASS) || defined(CUSTOMIZATION_BUILD_SECOND_PASS)
  1742. CURR_SCREEN_RESOURCE gsCurrScreenInfo;
  1743. extern CUSTOM_MENU nCustMenus[MAX_MENU_ITEMS];
  1744. extern U16 CurrMaxMenuItemIndex;
  1745. /*****************************************************************************
  1746.  * FUNCTION
  1747.  *  SetCurrentScreenStrings
  1748.  * DESCRIPTION
  1749.  *  SEt the current screen strings
  1750.  * PARAMETERS
  1751.  *  nNum        [IN]        ..
  1752.  * RETURNS
  1753.  *  void
  1754.  *****************************************************************************/
  1755. void SetCurrentScreenStrings(U16 nNum, ...)
  1756. {
  1757.     /*----------------------------------------------------------------*/
  1758.     /* Local Variables                                                */
  1759.     /*----------------------------------------------------------------*/
  1760.     U16 nId;
  1761.     U16 nCount = 0;
  1762.     va_list vlist;
  1763.     /*----------------------------------------------------------------*/
  1764.     /* Code Body                                                      */
  1765.     /*----------------------------------------------------------------*/
  1766.     va_start(vlist, nNum);
  1767.     gsCurrScreenInfo.nNoOfStrings = nNum;
  1768.     while (nNum > nCount)
  1769.     {
  1770.         nId = va_arg(vlist, U16);
  1771.         gsCurrScreenInfo.nStringIdList[nCount] = nId;
  1772.         ++nCount;
  1773.     }
  1774.     va_end(vlist);
  1775.     return;
  1776. }
  1777. /*****************************************************************************
  1778.  * FUNCTION
  1779.  *  SetCurrentScreenImages
  1780.  * DESCRIPTION
  1781.  *  SEt the current screen images
  1782.  * PARAMETERS
  1783.  *  nNum        [IN]        ..
  1784.  * RETURNS
  1785.  *  void
  1786.  *****************************************************************************/
  1787. void SetCurrentScreenImages(U16 nNum, ...)
  1788. {
  1789.     /*----------------------------------------------------------------*/
  1790.     /* Local Variables                                                */
  1791.     /*----------------------------------------------------------------*/
  1792.     U16 nId;
  1793.     U16 nCount = 0;
  1794.     va_list vlist;
  1795.     /*----------------------------------------------------------------*/
  1796.     /* Code Body                                                      */
  1797.     /*----------------------------------------------------------------*/
  1798.     va_start(vlist, nNum);
  1799.     gsCurrScreenInfo.nNoOfImages = nNum;
  1800.     while (nNum > nCount)
  1801.     {
  1802.         nId = va_arg(vlist, U16);
  1803.         gsCurrScreenInfo.nImageIdList[nCount] = nId;
  1804.         ++nCount;
  1805.     }
  1806.     va_end(vlist);
  1807.     return;
  1808. }
  1809. /*****************************************************************************
  1810.  * FUNCTION
  1811.  *  AppendCurrentScreenImages
  1812.  * DESCRIPTION
  1813.  *  SEt the current screen images
  1814.  * PARAMETERS
  1815.  *  nNum        [IN]        
  1816.  *  pList       [IN]        
  1817.  * RETURNS
  1818.  *  void
  1819.  *****************************************************************************/
  1820. void AppendCurrentScreenImages(int nNum, U16 *pList)
  1821. {
  1822.     /*----------------------------------------------------------------*/
  1823.     /* Local Variables                                                */
  1824.     /*----------------------------------------------------------------*/
  1825.     U16 nCount = 0;
  1826.     U16 i = 0;
  1827.     U8 flag = 0;
  1828.     U16 nOrgCount = gsCurrScreenInfo.nNoOfImages;
  1829.     /*----------------------------------------------------------------*/
  1830.     /* Code Body                                                      */
  1831.     /*----------------------------------------------------------------*/
  1832.     gsCurrScreenInfo.nNoOfImages = nNum + gsCurrScreenInfo.nNoOfImages;
  1833.     while (nNum > nCount)
  1834.     {
  1835.         flag = 0;
  1836.         //for(i = nOrgCount+1;i<(nOrgCount+nCount ) ;i++)
  1837.         //for(i = (nOrgCount+nCount);i>0 ;i--)
  1838.         for (i = 0; i < nCount; i++)
  1839.         {
  1840.             if (gsCurrScreenInfo.nImageIdList[i + nOrgCount] == pList[nCount])
  1841.             {
  1842.                 flag = 1;
  1843.                 break;
  1844.             }
  1845.         }
  1846.         if (flag == 0)
  1847.         {
  1848.             gsCurrScreenInfo.nImageIdList[nOrgCount + nCount] = pList[nCount];
  1849.         }
  1850.         ++nCount;
  1851.     }
  1852.     return;
  1853. }
  1854. /*****************************************************************************
  1855.  * FUNCTION
  1856.  *  AppendCurrentScreenStrings
  1857.  * DESCRIPTION
  1858.  *  SEt the current screen images
  1859.  * PARAMETERS
  1860.  *  nNum        [IN]        
  1861.  *  pList       [IN]        
  1862.  * RETURNS
  1863.  *  void
  1864.  *****************************************************************************/
  1865. void AppendCurrentScreenStrings(int nNum, U16 *pList)
  1866. {
  1867.     /*----------------------------------------------------------------*/
  1868.     /* Local Variables                                                */
  1869.     /*----------------------------------------------------------------*/
  1870.     U16 nCount = 0;
  1871.     U16 nOrgCount = gsCurrScreenInfo.nNoOfStrings;
  1872.     /*----------------------------------------------------------------*/
  1873.     /* Code Body                                                      */
  1874.     /*----------------------------------------------------------------*/
  1875.     gsCurrScreenInfo.nNoOfStrings = nNum + gsCurrScreenInfo.nNoOfStrings;
  1876.     while (nNum > nCount)
  1877.     {
  1878.         gsCurrScreenInfo.nStringIdList[nOrgCount + nCount] = pList[nCount];
  1879.         ++nCount;
  1880.     }
  1881.     return;
  1882. }
  1883. /*****************************************************************************
  1884.  * FUNCTION
  1885.  *  SetCurrentScreenMenus
  1886.  * DESCRIPTION
  1887.  *  SEt the current screen menus
  1888.  * PARAMETERS
  1889.  *  nNum        [IN]        ..
  1890.  * RETURNS
  1891.  *  void
  1892.  *****************************************************************************/
  1893. void SetCurrentScreenMenus(U16 nNum, ...)
  1894. {
  1895.     /*----------------------------------------------------------------*/
  1896.     /* Local Variables                                                */
  1897.     /*----------------------------------------------------------------*/
  1898.     U16 nId;
  1899.     U16 nCount = 0;
  1900.     U16 nParentIdCount = 0;
  1901.     va_list vlist;
  1902.     /*----------------------------------------------------------------*/
  1903.     /* Code Body                                                      */
  1904.     /*----------------------------------------------------------------*/
  1905.     va_start(vlist, nNum);
  1906.     gsCurrScreenInfo.nNoOfMenus = nNum;
  1907.     while (nNum > nCount)
  1908.     {
  1909.         nId = va_arg(vlist, U16);
  1910.         gsCurrScreenInfo.sMenuInfo[nCount].nId = nId;
  1911.         nParentIdCount = 0;
  1912.         while (nParentIdCount > CurrMaxMenuItemIndex)
  1913.         {
  1914.             if (nCustMenus[nParentIdCount].nMenuItemId == nId)
  1915.             {
  1916.                 gsCurrScreenInfo.sMenuInfo[nCount].nParentId = nCustMenus[nParentIdCount].nParentId;
  1917.                 break;
  1918.             }
  1919.             ++nParentIdCount;
  1920.         }
  1921.         ++nCount;
  1922.     }
  1923.     va_end(vlist);
  1924.     return;
  1925. }
  1926. #endif /* defined(CUSTOMIZATION_BUILD_FIRST_PASS) || defined(CUSTOMIZATION_BUILD_SECOND_PASS) */