blob: a605e272653f064f5e69bf7cf24184ddc2794e10 [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001#!/usr/bin/perl
2#
3# Copyright Statement:
4# --------------------
5# This software is protected by Copyright and the information contained
6# herein is confidential. The software may not be copied and the information
7# contained herein may not be used or disclosed except with the written
8# permission of MediaTek Inc. (C) 2008
9#
10# BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
11# THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
12# RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
13# AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
14# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
15# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
16# NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
17# SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
18# SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
19# THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
20# NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
21# SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
22#
23# BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
24# LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
25# AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
26# OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
27# MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
28#
29# THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
30# WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
31# LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
32# RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
33# THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
34#
35#
36# To process CustImgNamesExt and put image information to ExtractObj.ini.
37#******************************************************************************
38# Subroutine: Usage
39#******************************************************************************
40sub usage {
41 print "perl processCustPack.pl CustImgNamesExt ExtractObj.ini\n";
42 exit 1;
43}
44
45$CustImgNamesExt = $ARGV[0];
46$NvramLidSize = $ARGV[1];
47$NvramTmp = $ARGV[2];
48$NvramCustPack = $ARGV[3];
49$CustomWapCustPack = $ARGV[4];
50$CustpackAudio = $ARGV[5];
51$ThemeRes = $ARGV[6];
52$outputdir = $ARGV[7];
53$CustomPack = $ARGV[8];
54$templateCustomPack = $ARGV[9];
55$database = $ARGV[10];
56$symfile = $ARGV[11];
57$InputCustomPackPath = $ARGV[12];
58$CustVenusTheme = $ARGV[13];
59$NvramCustPackCerts = $ARGV[14];
60$NvramCustPackJavaCerts = $ARGV[15];
61if (defined $ARGV[16]) {
62$IfWapSupport = $ARGV[16];
63}
64$theme_file = 0;
65$lid_name = 0;
66$lid_file = 0;
67$wap_num = 0;
68$wap_data = 0;
69$wap_file = 0;
70chomp($cwd = `cd`);
71if ($cwd =~ /.*\\$/){
72 chop($cwd);
73}
74
75
76
77
78#$backup = $/;
79#undef $/;
80#$reading=<F>;
81#$/ = $backup;
82#close(F);
83
84# Convert to absolute path
85#$reading =~ s/=\s+"(\S)/= "$cmd$1/g;
86
87if (-e "$templateCustomPack") {
88 if($templateCustomPack =~ /(.+)\\custpack\.ini/i){
89 $originalCustPackPath = $1;
90 }
91 system ("move /y $templateCustomPack $originalCustPackPath\\~custpack.ini");
92}
93open (File,"<$originalCustPackPath\\~custpack.ini") || die "Cannot open the reference custpack file:$!\n";
94$backup = $/;
95undef $/;
96$template=<File>;
97$/ = $backup;
98close(File);
99
100my $isLCMMI = 0;
101if($CustImgNamesExt =~ /plutommi/i)
102{
103 $isLCMMI = 0;
104}
105elsif($CustImgNamesExt =~ /lcmmi/i)
106{
107 $isLCMMI = 1;
108}
109
110open (W,">$CustomPack") || die "Cannot open $CustomPack:$!\n";
111
112# [Setting]
113print W "[Setting]\n";
114print W "Input_CustPack_ROM_PATH = \"$cwd\\$InputCustomPackPath\\CUSTPACK_ROM\"\n";
115print W "OutputBin_PATH = \"$cwd\\$outputdir\\CUSTPACK_ROM\"\n";
116print W "Database_PATH = \"$cwd\\$database\"\n";
117if (-e $database) {
118 system("copy /y $database $outputdir");
119} else {
120 print "Warning! $database does not exist!\n";
121}
122# Get CustPackResPreamble from sym file or Execution Region CUSTPACK_ROM from lis file.
123open (FILE,"<$symfile") || die "Cannot find SYM file:$!\n";
124while (<FILE>) {
125 if ($_ =~ /(.+?)\s*\w+\s*CustPackResPreamble/) {
126 $StartAddress = $1;
127 }
128 if ($_ =~ /(.+?)\s*\w+\s*LangPackResPreamble/) {
129 $LangPack_StartAddress = $1;
130 }
131}
132close (FILE);
133print W "StartAddress = \"$StartAddress\"\n";
134print W "CUSTPACK_Version = \"0001\"\n";
135#print W "Input_ThirdROM_PATH = \"$cwd\\$InputCustomPackPath\\THIRD_ROM\"\n";
136#print W "Output_ThirdROM_PATH = \"$cwd\\$outputdir\\THIRD_ROM\"\n";
137#if(0 == $isLCMMI){
138# print W "LangPack_StartAddress = \"$LangPack_StartAddress\"\n";
139# print W "Input_LANG_PACK_ROM_PATH = \"$cwd\\$InputCustomPackPath\\LANG_PACK_ROM\"\n";
140# print W "Output_LANG_PACK_PATH = \"$cwd\\$outputdir\\LANG_PACK_ROM\"\n";
141#}
142#if (-e "$cwd\\$InputCustomPackPath\\THIRD_ROM") {
143# print W "ThirdROM_Exist = TRUE\n\n";
144#} else {
145# print W "ThirdROM_Exist = FALSE\n\n";
146#}
147print W ";set Disable_WAP = 1 for Low Cost MMI\n";
148if ($IfWapSupport == 1) {
149 print W "Disable_WAP = 0\n\n";
150} else {
151 print W "Disable_WAP = 1\n\n";
152}
153
154if($CustImgNamesExt =~ /plutommi/i)
155{
156 print W "LCMMI = 0\n\n";
157}
158elsif($CustImgNamesExt =~ /lcmmi/i)
159{
160 print W "LCMMI = 1\n\n";
161}
162
163if ($template =~ /(.+)\[Image\]/isg) {
164 $template = $';#'
165# print W $1;
166}
167
168# [Image]
169# Process custom\app\$(strip $(BOARD_VER))\nvram_cust_pack.c to get LID and NVRAM variable names.
170
171open (F,"<$CustImgNamesExt") || die "Cannot open CustImgNamesExt $CustImgNamesExt:$!\n";
172
173while(<F>)
174{
175 if (m/(\S+)\s+=\s+\"(\S+)\"/)
176 {
177 $reading .= $1 . " = " . '"' . $cwd . '\\' . $2 . '"' . "\n";
178 }
179}
180close(F);
181print W "[Image]\n";
182print W $reading;
183# [Font]
184#if (0 == $isLCMMI){
185# my $fontReading;
186# my $countFont = 0;
187# open (FONTEXT,"<$CustFontNamesExt") || die "Cannot open CustFontNamesExt $CustFontNamesExt:$!\n";
188# while(<FONTEXT>)
189# {
190# if (m/(\S+)\s+=\s+\"(\S+)\"/)
191# {
192# $fontReading .= $1 . " = " . '"' . $cwd . '\\' . $2 . '"' . "\n";
193# $countFont++;
194# }
195# }
196# close(F);
197# if($countFont > 0){
198# print W "[Font]\n";
199# print W $fontReading;
200# }
201#}
202# [Theme]
203# Process plutommi\Customer\CustResource\ThemeRes.c to get MMI_theme names.
204#open (F,"<$ThemeRes") || die "Cannot open ~ThemeRes.c $ThemeRes:$!\n";
205#$backup = $/;
206#undef $/;
207#$reading=<F>;
208#$/ = $backup;
209#close(F);
210
211
212if ($ThemeRes =~ /.+\\(.+?)\.bin/ig) {
213 print "$ThemeRes\n";
214 if (-e "$ThemeRes\\$1") {
215 print W "\n[Theme]\n";
216 print W "THEME_FILE = \"$cwd\\$ThemeRes\\$1\"\n";
217 }
218 elsif(-e "$ThemeRes") {
219 print W "\n[Theme]\n";
220 print W "THEME_FILE = \"$cwd\\$ThemeRes\"\n";
221 }
222 else{
223 print "Skip write Theme\n";
224 }
225}
226#if ($reading =~ /const MMI_theme \*mtk_MMI_themes\[.*\]\s*=\s*\{\s*(.+\s*.+\s*.+\s*.+\s*)\}/){
227# $mmi_theme = $1;
228# $theme_file++;
229# print W "THEME_FILE$theme_file = MMI_theme\n";
230#} elsif ($reading =~ /const theme_details_struct mtk_MMI_themes\[.*\]=\{\s*(.+?)\};/is) {
231# $theme_details_struct = $1;
232# $theme_file++;
233# print W "THEME_FILE$theme_file = theme_details_struct\n";
234#}
235#const theme_details_struct mtk_MMI_themes[ 3 ]={
236#if (defined $mmi_theme){
237# while ($mmi_theme =~ /.+&(.+?)[,\s]/){
238# $mmi_theme = $';
239# $theme_file++;
240# print W "THEME_FILE$theme_file = \"$outputdir\\$1\.bin\"\n";
241# }
242#}
243#if (defined $theme_details_struct){
244# while ($theme_details_struct =~ /.+&(.+?)[,\s]/){
245# $theme_details_struct = $';
246# $theme_file++;
247# print W "THEME_FILE$theme_file = \"$outputdir\\$1\.bin\"\n";
248# }
249#}
250
251# [AutoGenAudio]
252open (Custpackaudio,"<$CustpackAudio") || die "Cannot open CustAdoNamesExt $CustpackAudio:$!\n";
253
254my $readingfile = '';
255
256
257while(<Custpackaudio>)
258{
259 if (m/(\S+)\s+=\s+\"(\S+)\"/)
260 {
261 $readingfile .= $1 . " = " . '"' . $cwd . '\\' . $2 . '"' . "\n";
262 }
263}
264
265print $cwd,"\n";
266close(Custpackaudio);
267print W "[AutoGenAudio]\n";
268print W $readingfile;
269
270#[venus theme]
271print W "\n";
272if(-e $CustVenusTheme){
273 open (CUSTVENUSTHEME,"<$CustVenusTheme") || die "Cannot open VenusTheme.ini\n";
274 $backup = $/;
275 undef $/;
276 my $reading = <CUSTVENUSTHEME>;
277 $/ = $backup;
278 close CUSTVENUSTHEME;
279 print W $reading;
280}
281
282open (nvramtmp,"<$NvramTmp") || die "Cannot open ~nvram_tmp.c\n";
283$backup = $/;
284undef $/;
285my $reading = <nvramtmp>;
286$orig_reading = $reading;
287$/ = $backup;
288close nvramtmp;
289
290# [NVRAM]
291# Process custom\app\$(strip $(BOARD_VER))\nvram_cust_pack.c to get NVRAM and LID variable names.
292$count = 0;
293open (NvramLidSize,"<$NvramLidSize") || die "Cannot open ~nvram_lid_size.log, please execute nvram_auto_gen first:$!\n";
294while (<NvramLidSize>)
295{
296 if (/(\d+)\s*(\d+)\s*(\w.+\w)\s*\bCUSTPACK\b/){
297 if(!defined $nvram_name{$3}) {
298 $count++;
299 $nvram_name{$3} = $count;
300 } else {
301 next;
302 }
303 }
304}
305close(NvramLidSize);
306
307open (nvramtmp,"<$NvramTmp") || die "Cannot open ~nvram_tmp.c\n";
308$backup = $/;
309undef $/;
310my $reading = <nvramtmp>;
311$orig_reading = $reading;
312$/ = $backup;
313close nvramtmp;
314
315print W "\n[NVRAM]\n";
316print W "\;the order of following LID_NAME and LID_FILE must be same as their appearing in nvram_cust_pack.c\n";
317print W "\;plz note that sometimes some of them will disappear because of different compile combinations\n";
318# Add LID_NAME
319
320while ($reading =~ /\{\s*(NVRAM_[\w\d]+)\s*,\s*([^,]+),\s*([^,]+),\s*([^,]+),\s*[^,]+,\s*[^,]+,\s*([^,]+),[^\}]+\}\s*/)
321{
322 $reading =$';#'
323
324 my %this_app = ();
325 $this_app{APPLICATION} = $1;
326 $this_app{UNIT_SIZE} = $2;
327 $this_app{RECORD_NUM} = $3;
328 $this_app{NVRAM_VALUE} = $4;
329 $this_app{APP_NAME} = $5;
330 next unless ($this_app{APP_NAME} =~ /\"/);
331
332 $this_app{UNIT_SIZE} =~ s/\s//g;
333 $this_app{RECORD_NUM} =~ s/\s//g;
334 $this_app{APP_NAME} =~ s/^\"(.+)\\0\"$/$1/;
335 if (defined $nvram_name{"$this_app{APPLICATION}"}){
336 $lid_count{$nvram_name{"$this_app{APPLICATION}"}} = $this_app{APPLICATION};
337 }
338}
339
340for ($i=1;$i<=$count;$i++){
341 $lid_name++;
342 print W "LID_NAME$lid_name = \"$lid_count{$i}\"\n";
343}
344
345# Add LID_FILE
346open (NvramCustPack,"<$NvramCustPack") || die "Cannot open ~nvram_cust_pack.c\n";
347$backup = $/;
348undef $/;
349my $reading = <NvramCustPack>;
350$/ = $backup;
351close NvramCustPack;
352
353if ($reading =~ /const custpack_nvram_header custpack_nvram_ptr\s*=\s*\{.+?\{(.+?)\}/s) {
354 $nvram_variable = $1;
355}
356
357while($nvram_variable =~ /(\w+)[,|\s]/){
358 $nvram_variable=$';#'
359 $lid_file++;
360 print W "LID_FILE$lid_file = \"$cwd\\$outputdir\\BIN\\$1\.bin\"\n";
361}
362
363# Process custom\common\custom_wap_cust_pack.c to get custpack_wap_ptr variable names.
364open (F2,"<$CustomWapCustPack") || die "Cannot open ~custom_wap_cust_pack.c $CustomWapCustPack:$!\n";
365$backup = $/;
366undef $/;
367$reading=<F2>;
368$/ = $backup;
369close(F2);
370
371if ($reading =~ /typedef struct\s*\{([\w|\s|;|\*]+)\}\s*wap_custpack_header/) {
372 $wap_custpack_header = $1;
373 $wap_custpack_num_use = $1;
374}
375
376if ($reading =~ /const wap_custpack_header custpack_wap_ptr\s*=\s*\{([\w|\s|,|&]+)\}/) {
377 $custpack_wap_ptr = $1;
378}
379
380if (defined $ARGV[16]) {
381 print W "\n\[WAP\]\n";
382 while($wap_custpack_num_use =~ /\s*(.+?)\s*const/){
383 $wap_custpack_num_use = $';#'
384 $wap_num++;
385 }
386 print W "WAP DATA NUM = $wap_num\n";
387}
388
389while($wap_custpack_header =~ /\s*(.+?)\s*const/){
390 $wap_custpack_header = $';#'
391 $wap_data++;
392 print W "WAP_DATA$wap_data = \"$1\"\n";
393}
394
395while($custpack_wap_ptr =~ /&(.+?)[,|\s]/){
396 $custpack_wap_ptr = $';#'
397 $wap_file++;
398 print W "WAP_FILE$wap_file = \"$cwd\\$outputdir\\BIN\\$1.bin\"\n";
399}
400
401if(-e $NvramCustPackCerts){
402 $cafolder="${outputdir}\\root_ca";
403 if(!-e $cafolder){
404 $command="md $cafolder";
405 system("$command");
406 }
407 open (CERTFILEHANDL,"<$NvramCustPackCerts") || die "Cannot open ~custom_custpack_certs.c $NvramCustPackCerts:$!\n";
408 $backup = $/;
409 undef $/;
410 $reading=<CERTFILEHANDL>;
411 $/ = $backup;
412 close(CERTFILEHANDL);
413 $reading =~ /custpack_root_ca_header_struct\s+custpack_root_ca\s+=\s*\{(.+?)\}\;/s;
414 @hotlines = split /\n/,$1;
415 $cert_file_num = 0;
416 $namelist = 1;
417 for $line(@hotlines){
418 if($line =~ /^\s*$/){
419 next;
420 }
421 if($line =~ /^#line/){
422 next;
423 }
424 if($line =~ /^\s*\}\s*$/){
425 next;
426 }
427 if($line =~ /^\s*\{\s*$/){
428 next;
429 }
430 if($line =~ /^\s*\(*(\d+)\)*,\s*$/){
431 $cert_file_num = $1;
432 next;
433 }
434 @sections = split /,/,$line;
435 $cert_name;
436 $cert_format;
437 $cert_domain;
438 $cert_readonly;
439 if($sections[0] =~ /^\s*\{+\s*(\S+)\s*$/){
440 $cert_name = $1;
441 }
442 else{
443 print "Get cert name error.\n";
444 }
445 if($sections[2] =~ /\s*\((\d+)\)\s*/){
446 $cert_format = $1;
447 }
448 else{
449 print "Get format section error.\n";
450 }
451 if($sections[3] =~ /\s*\((\d+)\)\s*/){
452 $cert_domain = $1;
453 }
454 else{
455 print "Get domain section error.\n";
456 }
457 if($sections[4] =~ /\s*\((\d+)\)\s*/){
458 $cert_readonly = $1;
459 }
460 else{
461 print "Get readonly setion error.\n";
462 }
463 $cert_content;
464 if($reading =~ /${cert_name}\[\] \=\s*\{(.+?)\}/s){
465 $cert_content = $1;
466 }
467 $certs{$namelist}=[$cert_format,$cert_domain,$cert_readonly,$cert_content,$cert_name];
468 $namelist++;
469 }
470 print W "\n\n";
471 # Certificate
472 print W "\;Certificate\n";
473 print W "\;The following section is an example\n";
474 print W "\[Certificate\]\n";
475 print W "\; File number need to match the number of files listed below\n";
476 print W "CERT_FILE_NUM=${cert_file_num}\n\n";
477 print W "\; Domain : 0 for manufacture (default), 1 for operator, 2 for 3rd party\n";
478 print W "\; Format : 0 for X.509 certificate (default), 1 for WTLS\n";
479 for (sort by_number keys %certs){
480 print W "CERT_FILE".$_."_FORMAT = ".$certs{$_}[0]."\n";
481 print W "CERT_FILE".$_."_DOMAIN = ".$certs{$_}[1]."\n";
482 print W "CERT_FILE".$_."_READONLY = ".$certs{$_}[2]."\n";
483 $cert_filename = $outputdir."\\root_ca\\".$certs{$_}[4]."\.der";
484 open CERTFILE,">$cert_filename" or die "Can not open $cert_filename\n";
485 binmode CERTFILE;
486 while($certs{$_}[3] =~ /(0x\S\S)/){
487 $cerl=$1;
488 $cerl=hex $1;
489 $certs{$_}[3] =~ s/(0x\S\S)/ /;
490 print CERTFILE pack("c1", $cerl);
491 }
492 close CERTFILE;
493 print W "CERT_FILE".$_." = $cwd\\".$cert_filename."\n";
494 }
495}
496else{
497 print "not exits $NvramCustPackCerts\n";
498}
499undef %certs;
500print W "\n";
501if(-e $NvramCustPackJavaCerts){
502 print "Java certs\n";
503 $cafolder="${outputdir}\\java_ca";
504 if(!-e $cafolder){
505 $command="md $cafolder";
506 system("$command");
507 }
508 open (CERTFILEHANDL,"<$NvramCustPackJavaCerts") || die "Cannot open ~custom_custpack_java_certs.c $NvramCustPackJavaCerts:$!\n";
509 $backup = $/;
510 undef $/;
511 $reading=<CERTFILEHANDL>;
512 $/ = $backup;
513 close(CERTFILEHANDL);
514 $reading =~ /custpack_java_root_ca_header_struct\s+custpack_java_root_ca\s+=\s*\{(.+?)\}\;/s;
515 @hotlines = split /\n/,$1;
516 $cert_file_num = 0;
517 $namelist = 1;
518 for $line(@hotlines){
519 if($line =~ /^\s*$/){
520 next;
521 }
522 if($line =~ /^#line/){
523 next;
524 }
525 if($line =~ /^\s*\}\s*$/){
526 next;
527 }
528 if($line =~ /^\s*\{\s*$/){
529 next;
530 }
531 if($line =~ /^\s*\(*(\d+)\)*,\s*$/){
532 $cert_file_num = $1;
533 next;
534 }
535 @sections = split /,/,$line;
536 $cert_name;
537 $cert_format;
538 $cert_domain;
539 $cert_readonly;
540 if($sections[0] =~ /^\s*\{+\s*(\S+)\s*$/){
541 $cert_name = $1;
542 }
543 else{
544 print "Get cert name error.\n";
545 }
546 if($sections[2] =~ /\s*\((\d+)\)\s*/){
547 $cert_format = $1;
548 }
549 else{
550 print "Get format section error.\n";
551 }
552 if($sections[3] =~ /\s*\((\d+)\)\s*/){
553 $cert_domain = $1;
554 }
555 else{
556 print "Get domain section error.\n";
557 }
558 if($sections[4] =~ /\s*\((\d+)\)\s*/){
559 $cert_readonly = $1;
560 }
561 else{
562 print "Get readonly setion error.\n";
563 }
564 $cert_content;
565 if($reading =~ /${cert_name}\[\] \=\s*\{(.+?)\}/s){
566 $cert_content = $1;
567 }
568 $certs{$namelist}=[$cert_format,$cert_domain,$cert_readonly,$cert_content,${cert_name}];
569 $namelist++;
570 }
571
572 print W "\[JAVA Certificate\]\n";
573 print W "\; File number need to match the number of files listed below\n";
574 print W "CERT_FILE_NUM=${cert_file_num}\n";
575 print W "\; Domain : 0 for manufacture (Default), 1 for operator, 2 for 3rd party\n";
576
577 for (sort by_number keys %certs){
578 print W "CERT_FILE".$_."_FORMAT = ".$certs{$_}[0]."\n";
579 print W "CERT_FILE".$_."_DOMAIN = ".$certs{$_}[1]."\n";
580 print W "CERT_FILE".$_."_READONLY = ".$certs{$_}[2]."\n";
581 $cert_filename = $outputdir."\\java_ca\\".$certs{$_}[4]."\.cer";
582 open CERTFILE,">$cert_filename" or die "Can not open $cert_filename\n";
583 binmode CERTFILE;
584 while($certs{$_}[3] =~ /(0x\S\S)/){
585 $cerl=$1;
586 $cerl=hex $1;
587 $certs{$_}[3] =~ s/(0x\S\S)/ /;
588 print CERTFILE pack("c1", $cerl);
589 }
590 close CERTFILE;
591 print W "CERT_FILE".$_." = $cwd\\".$cert_filename."\n";
592 }
593}
594
595if (!defined $ARGV[16]) {
596 if ($template =~ /(.+)\;Variable/isg) {
597 print W "\n\;Variable";
598 }
599} else {
600 if ($template =~ /(.+)\[Variable\]/isg) {
601 $template = $';#'
602 print W "\n\[Variable\]";
603 print W $template;
604 }
605}
606
607close(W);
608
609
610sub by_number {
611 if($a < $b){-1} elsif($a > $b){1} else {0};
612}