sl@0: # sl@0: # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: # All rights reserved. sl@0: # This component and the accompanying materials are made available sl@0: # under the terms of "Eclipse Public License v1.0" sl@0: # which accompanies this distribution, and is available sl@0: # at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: # sl@0: # Initial Contributors: sl@0: # Nokia Corporation - initial contribution. sl@0: # sl@0: # Contributors: sl@0: # sl@0: # Description: sl@0: # sl@0: #!perl sl@0: sl@0: use strict; sl@0: sl@0: my $file = $ARGV[0]; sl@0: sl@0: die "Usage: $0 filename\n" if (!$file); sl@0: die "ERROR: \"$file\" does not exist\n" if (!-f $file); sl@0: sl@0: &AddNoRedrawStoring($file) if($ARGV[3] =~ /^noredrawstoring$/i); sl@0: &AddAutoLine($file) if ($ARGV[2] =~ /^auto$/i); sl@0: &AddMultiLine($file) if ($ARGV[1] =~ /^multiscreen$/i); sl@0: sl@0: sl@0: # This function adds a line to a wsini.ini so that it runs the tests in auto mode sl@0: # This functions assumes the file is in UTF16 sl@0: sub AddAutoLine sl@0: { sl@0: my $file = shift; sl@0: sl@0: my $string = &ascii_to_utf16('SHELLCMD AUTO'); sl@0: sl@0: &Write_UTF16_Newline($file); sl@0: sl@0: open(FILE, ">>$file") or warn "WARNING: Could not open file: $!\n"; sl@0: print FILE $string; sl@0: close FILE; sl@0: sl@0: &Write_UTF16_Newline($file); sl@0: } sl@0: sl@0: sl@0: # This function adds a line to a wsini.ini so that it runs in multiscreen sl@0: # This functions assumes the file is in UTF16 sl@0: sub AddMultiLine sl@0: { sl@0: my $file = shift; sl@0: sl@0: my $string0 = &ascii_to_utf16('[SCREEN0]'); sl@0: my $string1 = &ascii_to_utf16('[SCREEN1]'); sl@0: sl@0: &Write_UTF16_Newline($file); sl@0: sl@0: open(FILE0, ">>$file") or warn "WARNING: Could not open file: $!\n"; sl@0: print FILE0 $string0; sl@0: close FILE0; sl@0: &Write_UTF16_Newline($file); sl@0: sl@0: open(FILE1, ">>$file") or warn "WARNING: Could not open file: $!\n"; sl@0: print FILE1 $string1; sl@0: close FILE1; sl@0: &Write_UTF16_Newline($file); sl@0: } sl@0: sl@0: # This function adds a line to a wsini.ini so that it runs the tests with NOREDRAWSTORING flag sl@0: # This functions assumes the file is in UTF16 sl@0: sub AddNoRedrawStoring sl@0: { sl@0: my $file = shift; sl@0: sl@0: my $string = &ascii_to_utf16('NOREDRAWSTORING'); sl@0: sl@0: &Write_UTF16_Newline($file); sl@0: sl@0: open(FILE, ">>$file") or warn "WARNING: Could not open file: $!\n"; sl@0: print FILE $string; sl@0: close FILE; sl@0: sl@0: &Write_UTF16_Newline($file); sl@0: } sl@0: sl@0: sl@0: sub Write_UTF16_Newline sl@0: { sl@0: my $file = shift; sl@0: sl@0: open(BIN, ">>$file") or warn "WARNING: Could not open \"$file\": $!\n"; sl@0: binmode BIN; sl@0: sysseek BIN, 0, 'SEEK_END'; sl@0: syswrite BIN, "\x0D\x00\x0A\x00" or warn "WARNING: Could not write to file\n"; sl@0: close BIN; sl@0: } sl@0: sl@0: sl@0: sl@0: # Function that accepts an ASCII string and returns the same string in UTF16 sl@0: sub ascii_to_utf16 { sl@0: my $utf16_string = ""; sl@0: my $ascii_string = shift; sl@0: my $lengthofstring = length($ascii_string); sl@0: sl@0: for (my $count=1; $count<=$lengthofstring; $count++) sl@0: { sl@0: my $char = substr($ascii_string,$count-1,1); sl@0: $utf16_string .= $char; sl@0: $utf16_string .= "\x00"; sl@0: } sl@0: sl@0: return $utf16_string; sl@0: }