-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: http://dev.corsaair.com/svn/as3-universal-analytics/trunk@35 13dad66c-d88e-4d4d-a296-e493d2cc3f1e
- Loading branch information
Showing
60 changed files
with
11,301 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package C.unistd | ||
{ | ||
import C.stdlib.*; // getenv, exit, EXIT_SUCCESS, EXIT_FAILURE | ||
import C.unistd.*; // access, X_OK, getlogin | ||
import C.sys.stat.*; // stat, status, S_ISREG, S_IXUSR, S_IXGRP, S_IXOTH | ||
|
||
/** | ||
* Locate a program file in the user's path. | ||
* | ||
* <p> | ||
* The <b>which</b> utility takes a command name and searches the path | ||
* for each executable file that would be run had this | ||
* command actually been invoked. | ||
* </p> | ||
* | ||
* @example Usage | ||
* <listing> | ||
* trace( "which bash = " + which( "bash" ) ); //output: which bash = /bin/bash | ||
* trace( "which svn = " + which( "svn", true ) ); //output: which svn = /opt/local/bin/svn /usr/bin/svn | ||
* </listing> | ||
* | ||
* @param name program name to look for. | ||
* @param all if <code>true</code> list all instances of executables found. | ||
* @return the full path of the program or the empty string if not found. | ||
* | ||
* @langversion 3.0 | ||
* @playerversion AVM 0.4 | ||
* @playerversion POSIX + | ||
* | ||
* @see http://docs.redtamarin.com/latest/C/stdlib/package.html#getenv() C.stdlib.getenv() | ||
* @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/getenv.html getenv() | ||
* @see http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script Check if a program exists from a bash script | ||
* @see http://www.opensource.apple.com/source/shell_cmds/shell_cmds-170/which/which.c shell command which | ||
*/ | ||
public function which( name:String, all:Boolean = false ):String | ||
{ | ||
var PATH:String = getenv( "PATH" ); | ||
if( PATH == "" ) { return ""; } | ||
|
||
/* Note: | ||
usual paths are | ||
/opt/local/bin | ||
/opt/local/sbin | ||
/usr/local/bin | ||
/usr/bin | ||
/bin | ||
/usr/sbin | ||
/sbin | ||
*/ | ||
var paths:Array = PATH.split( ":" ); | ||
paths.push( "." ); | ||
|
||
var is_there:Function = function( candidate:String ):Boolean | ||
{ | ||
var fin:* = new status(); | ||
/* Note: | ||
getlogin() != "root" | ||
should be | ||
getuid() != 0 | ||
*/ | ||
if( (access( candidate, X_OK ) == 0) && | ||
(stat( candidate, fin ) == 0) && | ||
S_ISREG( fin.st_mode ) && | ||
( (getlogin() != "root") || | ||
((fin.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) != 0) ) ) | ||
{ | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
var found:String = ""; | ||
|
||
var i:uint; | ||
var len:uint = paths.length; | ||
var candidate:String; | ||
for( i = 0; i < len; i++ ) | ||
{ | ||
candidate = paths[i] + "/" + name; | ||
if( is_there( candidate ) ) | ||
{ | ||
if( all ) | ||
{ | ||
found += (found == "" ? "": " ") + candidate; | ||
} | ||
else | ||
{ | ||
return candidate; | ||
} | ||
} | ||
} | ||
|
||
return found; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package | ||
{ | ||
import flash.display.Sprite; | ||
|
||
/** | ||
* The basic framework Library to be included in the SWC. | ||
* | ||
* <p> | ||
* <b>Note:</b> This class is not a component, it is just | ||
* a shim that allow to declare the SWC manifest and associate an icon file. | ||
* </p> | ||
*/ | ||
[ExcludeClass] | ||
[IconFile("uanalytics.png")] | ||
public class Library extends Sprite | ||
{ | ||
public function Library() | ||
{ | ||
super(); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package crypto | ||
{ | ||
import flash.utils.ByteArray; | ||
|
||
import shell.Program; | ||
|
||
/** | ||
* Generates a sequence of random bytes. | ||
* | ||
* <p> | ||
* Use <code>generateRandomBytes()</code> to generate cryptographic keys, | ||
* strong identifiers, session ids, and so on. | ||
* The random sequence is generated using cryptographically strong functions | ||
* provided by the operating system. | ||
* If the appropriate function is not available on an individual client | ||
* computer or device, then an error is thrown. | ||
* </p> | ||
* | ||
* <p> | ||
* <b>Note:</b> this is a temporary solution as the current redtamarin runtimes | ||
* does not implment <code>flash.crypto.generateRandomBytes</code> yet.<br> | ||
* It will work under Linux and Mac OS X but not under Windows (unless under a cygwin shell). | ||
* </p> | ||
* | ||
* @param numberRandomBytes the number of random bytes to generate, between 1 and 1024. | ||
* @return a ByteArray containing the generated bytes. | ||
* | ||
* @playerversion AVM 0.4 | ||
* @playerversion POSIX + | ||
* @langversion 3.0 | ||
* | ||
* @see http://en.wikipedia.org/wiki//dev/random /dev/random | ||
* @see http://stackoverflow.com/questions/3690273/did-i-understand-dev-urandom Did I understand /dev/urandom? | ||
*/ | ||
public function generateRandomBytes( numberRandomBytes:uint ):ByteArray | ||
{ | ||
if( numberRandomBytes < 1 ) | ||
{ | ||
numberRandomBytes = 1; | ||
} | ||
|
||
if( numberRandomBytes > 1024 ) | ||
{ | ||
numberRandomBytes = 1024; | ||
} | ||
|
||
var bytes:ByteArray = new ByteArray(); | ||
|
||
var get2bytes:Function = function():uint | ||
{ | ||
/* Note: | ||
This will only work under Linux and Mac OS X and only if | ||
"/dev/urandom" is available. | ||
We should test its presence and thorw an error if not found. | ||
*/ | ||
var str:String = Program.open( "LC_CTYPE=C tr -dc 'A-F0-9' < /dev/urandom | head -c 2" ); | ||
var b:uint = parseInt( "0x" + str ); | ||
return b; | ||
} | ||
|
||
var i:uint; | ||
for( i = 0; i < numberRandomBytes; i++ ) | ||
{ | ||
bytes.writeByte( get2bytes() ); | ||
} | ||
|
||
bytes.position = 0; | ||
return bytes; | ||
} | ||
} |
Oops, something went wrong.