Compare commits
1 Commits
test_unit
...
tags/mozbo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
199e57d10e |
@@ -1 +0,0 @@
|
||||
Another clobber to see about the orange... :(
|
||||
@@ -1,26 +0,0 @@
|
||||
#
|
||||
## hostname: gaius
|
||||
## uname: WINNT GAIUS 5.2 3790 xx I386
|
||||
#
|
||||
|
||||
|
||||
# . $topsrcdir/browser/config/mozconfig
|
||||
|
||||
mk_add_options MOZ_CO_PROJECT=browser
|
||||
##mk_add_options MOZ_MAKE_FLAGS="-j8"
|
||||
#mk_add_options MOZ_CO_MODULE="mozilla/tools/update-packaging"
|
||||
mk_add_options MOZ_PACKAGE_NSIS=1
|
||||
|
||||
ac_add_options --enable-application=browser
|
||||
ac_add_options --enable-update-channel=nightly
|
||||
ac_add_options --enable-optimize
|
||||
ac_add_options --disable-debug
|
||||
# ac_add_options --enable-codesighs
|
||||
ac_add_options --enable-tests
|
||||
ac_add_options --disable-static
|
||||
# ac_add_options --disable-shared
|
||||
# ac_add_options --enable-official-branding
|
||||
ac_add_options --enable-svg
|
||||
ac_add_options --enable-canvas
|
||||
ac_add_options --enable-default-toolkit=cairo-windows
|
||||
#ac_add_options --enable-update-packaging
|
||||
@@ -1,254 +0,0 @@
|
||||
#
|
||||
## hostname: gaius
|
||||
## uname: WINNT GAIUS 5.2 3790 xx I386
|
||||
#
|
||||
|
||||
#- tinder-config.pl - Tinderbox configuration file.
|
||||
#- Uncomment the variables you need to set.
|
||||
#- The default values are the same as the commented variables.
|
||||
|
||||
$ENV{MOZ_INSTALLER_USE_7ZIP} = '1';
|
||||
$ENV{NO_EM_RESTART} = '1';
|
||||
$ENV{MOZ_PACKAGE_NSIS} = '1';
|
||||
|
||||
# $ENV{MOZ_PACKAGE_MSI}
|
||||
#-----------------------------------------------------------------------------
|
||||
# Default: 0
|
||||
# Values: 0 | 1
|
||||
# Purpose: Controls whether a MSI package is made.
|
||||
# Requires: Windows and a local MakeMSI installation.
|
||||
#$ENV{MOZ_PACKAGE_MSI} = 0;
|
||||
|
||||
# $ENV{MOZ_SYMBOLS_TRANSFER_TYPE}
|
||||
#-----------------------------------------------------------------------------
|
||||
# Default: scp
|
||||
# Values: scp | rsync
|
||||
# Purpose: Use scp or rsync to transfer symbols to the Talkback server.
|
||||
# Requires: The selected type requires the command be available both locally
|
||||
# and on the Talkback server.
|
||||
#$ENV{MOZ_SYMBOLS_TRANSFER_TYPE} = "scp";
|
||||
|
||||
#- PLEASE FILL THIS IN WITH YOUR PROPER EMAIL ADDRESS
|
||||
$BuildAdministrator = 'build@mozilla.org';
|
||||
#$BuildAdministrator = "$ENV{USER}\@$ENV{HOST}";
|
||||
#$BuildAdministrator = ($ENV{USER} || "cltbld") . "\@" . ($ENV{HOST} || "dhcp");
|
||||
|
||||
$BuildXForms = 1;
|
||||
|
||||
#- You'll need to change these to suit your machine's needs
|
||||
#$DisplayServer = ':0.0';
|
||||
|
||||
#- Default values of command-line opts
|
||||
#-
|
||||
#$BuildDepend = 1; # Depend or Clobber
|
||||
#$BuildDebug = 0; # Debug or Opt (Darwin)
|
||||
#$ReportStatus = 1; # Send results to server, or not
|
||||
#$ReportFinalStatus = 1; # Finer control over $ReportStatus.
|
||||
#$UseTimeStamp = 1; # Use the CVS 'pull-by-timestamp' option, or not
|
||||
#$BuildOnce = 0; # Build once, don't send results to server
|
||||
#$TestOnly = 0; # Only run tests, don't pull/build
|
||||
#$BuildEmbed = 0; # After building seamonkey, go build embed app.
|
||||
#$SkipMozilla = 0; # Use to debug post-mozilla.pl scripts.
|
||||
#$BuildLocales = 0; # Do l10n packaging?
|
||||
|
||||
# Tests
|
||||
$CleanProfile = 1;
|
||||
#$ResetHomeDirForTests = 1;
|
||||
$ProductName = "Firefox";
|
||||
$VendorName = "Mozilla";
|
||||
|
||||
$RunMozillaTests = 1; # Allow turning off of all tests if needed.
|
||||
$RegxpcomTest = 0;
|
||||
$AliveTest = 0;
|
||||
#$JavaTest = 0;
|
||||
#$ViewerTest = 0;
|
||||
#$BloatTest = 0; # warren memory bloat test
|
||||
#$BloatTest2 = 0; # dbaron memory bloat test, require tracemalloc
|
||||
#$DomToTextConversionTest = 0;
|
||||
#$XpcomGlueTest = 0;
|
||||
$CodesizeTest = 0; # Z, require mozilla/tools/codesighs
|
||||
$EmbedCodesizeTest = 0; # mZ, require mozilla/tools/codesigns
|
||||
#$MailBloatTest = 0;
|
||||
#$EmbedTest = 0; # Assumes you wanted $BuildEmbed=1
|
||||
$LayoutPerformanceTest = 0; # Tp
|
||||
#$DHTMLPerformanceTest = 0; # Tdhtml
|
||||
#$QATest = 0;
|
||||
$XULWindowOpenTest = 0; # Txul
|
||||
#$StartupPerformanceTest = 1; # Ts
|
||||
#$NeckoUnitTest = 0;
|
||||
$RenderPerformanceTest = 0; # Tgfx
|
||||
|
||||
$RunUnitTests = 1;
|
||||
|
||||
$TestsPhoneHome = 1; # Should test report back to server?
|
||||
$GraphNameOverride = 'fxexp-win32-tbox';
|
||||
|
||||
# $results_server
|
||||
#----------------------------------------------------------------------------
|
||||
# Server on which test results will be accessible. This was originally tegu,
|
||||
# then became axolotl. Once we moved services from axolotl, it was time
|
||||
# to give this service its own hostname to make future transitions easier.
|
||||
# - cmp@mozilla.org
|
||||
#$results_server = "build-graphs.mozilla.org";
|
||||
|
||||
$pageload_server = "pageload.build.mozilla.org"; # localhost
|
||||
|
||||
#
|
||||
# Timeouts, values are in seconds.
|
||||
#
|
||||
#$CVSCheckoutTimeout = 3600;
|
||||
#$CreateProfileTimeout = 45;
|
||||
#$RegxpcomTestTimeout = 120;
|
||||
|
||||
#$AliveTestTimeout = 30;
|
||||
#$ViewerTestTimeout = 45;
|
||||
#$EmbedTestTimeout = 45;
|
||||
#$BloatTestTimeout = 120; # seconds
|
||||
#$MailBloatTestTimeout = 120; # seconds
|
||||
#$JavaTestTimeout = 45;
|
||||
#$DomTestTimeout = 45; # seconds
|
||||
#$XpcomGlueTestTimeout = 15;
|
||||
#$CodesizeTestTimeout = 900; # seconds
|
||||
#$CodesizeTestType = "auto"; # {"auto"|"base"}
|
||||
$LayoutPerformanceTestTimeout = 800; # entire test, seconds
|
||||
#$DHTMLPerformanceTestTimeout = 1200; # entire test, seconds
|
||||
#$QATestTimeout = 1200; # entire test, seconds
|
||||
#$LayoutPerformanceTestPageTimeout = 30000; # each page, ms
|
||||
#$StartupPerformanceTestTimeout = 20; # seconds
|
||||
#$XULWindowOpenTestTimeout = 90; # seconds
|
||||
#$NeckoUnitTestTimeout = 30; # seconds
|
||||
$RenderPerformanceTestTimeout = 1800; # seconds
|
||||
|
||||
#$MozConfigFileName = 'mozconfig';
|
||||
|
||||
#$UseMozillaProfile = 1;
|
||||
#$MozProfileName = 'default';
|
||||
|
||||
#- Set these to what makes sense for your system
|
||||
$Make = 'make'; # Must be GNU make
|
||||
#$MakeOverrides = '';
|
||||
#$mail = '/bin/mail';
|
||||
#$CVS = 'cvs -q';
|
||||
#$CVSCO = 'checkout -P';
|
||||
|
||||
# win32 usually doesn't have /bin/mail
|
||||
$blat = 'd:/moztools/bin/blat.exe';
|
||||
$use_blat = 1;
|
||||
|
||||
# Set moz_cvsroot to something like:
|
||||
# :pserver:$ENV{USER}%netscape.com\@cvs.mozilla.org:/cvsroot
|
||||
# :pserver:anonymous\@cvs-mirror.mozilla.org:/cvsroot
|
||||
#
|
||||
# Note that win32 may not need \@, depends on ' or ".
|
||||
# :pserver:$ENV{USER}%netscape.com@cvs.mozilla.org:/cvsroot
|
||||
|
||||
#$moz_cvsroot = $ENV{CVSROOT};
|
||||
$moz_cvsroot = ':ext:cltbld@cvs.mozilla.org:/cvsroot';
|
||||
|
||||
#- Set these proper values for your tinderbox server
|
||||
#$Tinderbox_server = 'tinderbox-daemon@tinderbox.mozilla.org';
|
||||
|
||||
# Allow for non-client builds, e.g. camino.
|
||||
#$moz_client_mk = 'client.mk';
|
||||
|
||||
#- Set if you want to build in a separate object tree
|
||||
#$ObjDir = 'fx-trunk-cairo';
|
||||
|
||||
# Extra build name, if needed.
|
||||
$BuildNameExtra = 'Unit Testing';
|
||||
|
||||
# User comment, eg. ip address for dhcp builds.
|
||||
# ex: $UserComment = "ip = 208.12.36.108";
|
||||
#$UserComment = 0;
|
||||
|
||||
#-
|
||||
#- The rest should not need to be changed
|
||||
#-
|
||||
|
||||
#- Minimum wait period from start of build to start of next build in minutes.
|
||||
#$BuildSleep = 10;
|
||||
|
||||
#- Until you get the script working. When it works,
|
||||
#- change to the tree you're actually building
|
||||
#$BuildTree = 'MozillaTest';
|
||||
#$BuildTree = 'Firefox-Cairo';
|
||||
$BuildTree = 'MozillaExperimental';
|
||||
|
||||
#$BuildName = '';
|
||||
#$BuildTag = '';
|
||||
#$BuildConfigDir = 'mozilla/config';
|
||||
#$Topsrcdir = 'mozilla';
|
||||
|
||||
$BinaryName = 'firefox.exe';
|
||||
|
||||
#
|
||||
# For embedding app, use:
|
||||
#$EmbedBinaryName = 'TestGtkEmbed';
|
||||
#$EmbedDistDir = 'dist/bin'
|
||||
|
||||
|
||||
#$ShellOverride = ''; # Only used if the default shell is too stupid
|
||||
#$ConfigureArgs = '';
|
||||
#$ConfigureEnvArgs = '';
|
||||
#$Compiler = 'gcc';
|
||||
#$NSPRArgs = '';
|
||||
#$ShellOverride = '';
|
||||
|
||||
# Release build options
|
||||
$ReleaseBuild = 0;
|
||||
$shiptalkback = 0;
|
||||
$ReleaseToLatest = 0; # Push the release to latest-<milestone>?
|
||||
$ReleaseToDated = 0; # Push the release to YYYY-MM-DD-HH-<milestone>?
|
||||
$build_hour = "4";
|
||||
$package_creation_path = "/browser/installer";
|
||||
# needs setting for mac + talkback: $mac_bundle_path = "/browser/app";
|
||||
$ssh_version = "2";
|
||||
#$ssh_user = "cltbld";
|
||||
#$ssh_server = "stage.mozilla.org";
|
||||
$ftp_path = "/home/ftp/pub/firefox/nightly";
|
||||
$url_path = "http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly";
|
||||
$tbox_ftp_path = "/home/ftp/pub/firefox/tinderbox-builds";
|
||||
$tbox_url_path = "http://ftp.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds";
|
||||
$milestone = "trunk";
|
||||
$notify_list = 'build-announce@mozilla.org';
|
||||
#$stub_installer = 0;
|
||||
#$sea_installer = 1;
|
||||
#$archive = 1;
|
||||
#$push_raw_xpis = 1;
|
||||
#$update_package = 1;
|
||||
#$update_product = "Firefox";
|
||||
#$update_version = "trunk";
|
||||
#$update_platform = "WINNT_x86-msvc";
|
||||
#$update_hash = "sha1";
|
||||
#$update_filehost = "ftp.mozilla.org";
|
||||
#$update_appv = "3.0a1";
|
||||
#$update_extv = "3.0a1";
|
||||
#$update_pushinfo = 0;
|
||||
|
||||
# Reboot the OS at the end of build-and-test cycle. This is primarily
|
||||
# intended for Win9x, which can't last more than a few cycles before
|
||||
# locking up (and testing would be suspect even after a couple of cycles).
|
||||
# Right now, there is only code to force the reboot for Win9x, so even
|
||||
# setting this to 1, will not have an effect on other platforms. Setting
|
||||
# up win9x to automatically logon and begin running tinderbox is left
|
||||
# as an exercise to the reader.
|
||||
#$RebootSystem = 0;
|
||||
|
||||
# LogCompression specifies the type of compression used on the log file.
|
||||
# Valid options are 'gzip', and 'bzip2'. Please make sure the binaries
|
||||
# for 'gzip' or 'bzip2' are in the user's path before setting this
|
||||
# option.
|
||||
#$LogCompression = '';
|
||||
|
||||
# LogEncoding specifies the encoding format used for the logs. Valid
|
||||
# options are 'base64', and 'uuencode'. If $LogCompression is set above,
|
||||
# this needs to be set to 'base64' or 'uuencode' to ensure that the
|
||||
# binary data is transferred properly.
|
||||
#$LogEncoding = '';
|
||||
|
||||
# Prevent Extension Manager from spawning child processes during tests
|
||||
# - processes that tbox scripts cannot kill.
|
||||
#$ENV{NO_EM_RESTART} = '1';
|
||||
|
||||
# Build XForms
|
||||
$BuildXForms = 1;
|
||||
2
mozilla/webtools/mozbot/README
Normal file
2
mozilla/webtools/mozbot/README
Normal file
@@ -0,0 +1,2 @@
|
||||
This is the source code for the "mozbot" robot that hangs out on the #mozilla
|
||||
irc channel (server irc.mozilla.org).
|
||||
101
mozilla/webtools/mozbot/Tinderbox.pm
Normal file
101
mozilla/webtools/mozbot/Tinderbox.pm
Normal file
@@ -0,0 +1,101 @@
|
||||
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Bugzilla Bug Tracking System.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape Communications
|
||||
# Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Harrison Page <harrison@netscape.com>
|
||||
# Terry Weissman <terry@mozilla.org>
|
||||
|
||||
# harrison@netscape.com
|
||||
#
|
||||
# 1.0 10/16/98
|
||||
|
||||
package Tinderbox;
|
||||
|
||||
require Exporter;
|
||||
|
||||
use strict 'vars';
|
||||
use vars qw (@ISA @EXPORT $VERSION);
|
||||
use LWP::Simple;
|
||||
# use HTML::Parse;
|
||||
use Carp;
|
||||
|
||||
@ISA = qw (Exporter);
|
||||
@EXPORT = qw (status statuz);
|
||||
|
||||
my $VERSION = "1.0";
|
||||
|
||||
# status wants a reference to a list of tinderbox trees
|
||||
# and a url ending with tree=, default to mozilla.org's
|
||||
# server if not provided. status returns two references
|
||||
# to hashes. the first contains tree names as key,
|
||||
# tree status as value. second hash contains trees to
|
||||
# whether or tree is open or closed.
|
||||
#
|
||||
# tree status can be horked or success.
|
||||
#
|
||||
# barf.
|
||||
|
||||
sub status
|
||||
{
|
||||
my $trees = shift;
|
||||
my $url = shift;
|
||||
my %info; my %tree_state;
|
||||
|
||||
# maybe this is too helpful
|
||||
|
||||
if (ref ($trees) ne "ARRAY")
|
||||
{
|
||||
carp "status method wants a reference to a list, not a " . ref ($trees);
|
||||
return;
|
||||
}
|
||||
|
||||
$url = $url || "http://tinderbox.mozilla.org/" .
|
||||
"showbuilds.cgi?quickparse=1&tree=";
|
||||
|
||||
my $output = get $url . join ',', @$trees;
|
||||
return if (! $output);
|
||||
|
||||
my @qp = split /\n/, $output;
|
||||
|
||||
# loop through quickparse output
|
||||
|
||||
foreach my $op (@qp)
|
||||
{
|
||||
my ($type, $tree, $build, $state) = split /\|/, $op;
|
||||
|
||||
if ($type eq "State")
|
||||
{
|
||||
$tree_state{$tree} = $state;
|
||||
}
|
||||
elsif ($type eq "Build")
|
||||
{
|
||||
if ($state =~ /success/i) {
|
||||
$state = "Success";
|
||||
} elsif ($state =~ /testfailed/i) {
|
||||
$state = "Test Failed";
|
||||
} else {
|
||||
$state = "Horked";
|
||||
}
|
||||
$info{$tree}{$build} = $state;
|
||||
}
|
||||
}
|
||||
|
||||
return (\%info, \%tree_state);
|
||||
}
|
||||
|
||||
1;
|
||||
160
mozilla/webtools/mozbot/babel.pm
Normal file
160
mozilla/webtools/mozbot/babel.pm
Normal file
@@ -0,0 +1,160 @@
|
||||
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Bugzilla Bug Tracking System.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape Communications
|
||||
# Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Terry Weissman <terry@mozilla.org>
|
||||
#
|
||||
#
|
||||
#
|
||||
# Most of this module is rudely swiped from infobot. Here are the various
|
||||
# licensing words I found with it:
|
||||
# --
|
||||
#
|
||||
# The license for this stuff is yet to be written.
|
||||
# Please don't do anything good with it without at
|
||||
# least mentioning this work, perhaps the author (Kevin
|
||||
# Lenzo, lenzo@cs.cmu.edu), and the Carnegie Mellon
|
||||
# University, which supports my study.
|
||||
#
|
||||
# Also, there is work being done on various bits of this
|
||||
# now by various people; if you have any corrections
|
||||
# or contributions, please send them to me. Flat
|
||||
# ascii files of databases, made with dump_db, are
|
||||
# wonderful things to share, and a repository will be
|
||||
# set up.
|
||||
#
|
||||
# ---
|
||||
#
|
||||
# This program is copyright Jonathan Feinberg 1999.
|
||||
#
|
||||
# This program is distributed under the same terms as infobot.
|
||||
#
|
||||
# Jonathan Feinberg
|
||||
# jdf@pobox.com
|
||||
# http://pobox.com/~jdf/
|
||||
#
|
||||
# Version 1.0
|
||||
# First public release.
|
||||
#
|
||||
# ---------------------- (End of licensing words) ------------------------
|
||||
|
||||
|
||||
package babel;
|
||||
use strict;
|
||||
use diagnostics;
|
||||
|
||||
my $no_babel;
|
||||
|
||||
BEGIN {
|
||||
eval "use URI::Escape"; # utility functions for encoding the
|
||||
if ($@) { $no_babel++}; # babelfish request
|
||||
eval "use LWP::UserAgent";
|
||||
if ($@) { $no_babel++};
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
# Translate some feasible abbreviations into the ones babelfish
|
||||
# expects.
|
||||
use vars qw!%lang_code $lang_regex!;
|
||||
%lang_code = (
|
||||
fr => 'fr',
|
||||
sp => 'es',
|
||||
po => 'pt',
|
||||
pt => 'pt',
|
||||
it => 'it',
|
||||
ge => 'de',
|
||||
de => 'de',
|
||||
gr => 'de',
|
||||
en => 'en'
|
||||
);
|
||||
|
||||
# Here's how we recognize the language you're asking for. It looks
|
||||
# like RTSL saves you a few keystrokes in #perl, huh?
|
||||
$lang_regex = join '|', keys %lang_code;
|
||||
}
|
||||
|
||||
|
||||
sub babelfish {
|
||||
return '' if $no_babel;
|
||||
my ($direction, $lang, $phrase) = @_;
|
||||
|
||||
$lang = $lang_code{$lang};
|
||||
|
||||
my $ua = new LWP::UserAgent;
|
||||
$ua->timeout(4);
|
||||
|
||||
my $req =
|
||||
HTTP::Request->new('POST',
|
||||
'http://babelfish.altavista.digital.com/cgi-bin/translate');
|
||||
$req->content_type('application/x-www-form-urlencoded');
|
||||
|
||||
my $tolang = "en_$lang";
|
||||
my $toenglish = "${lang}_en";
|
||||
|
||||
if ($direction eq 'to') {
|
||||
return translate($phrase, $tolang, $req, $ua);
|
||||
}
|
||||
elsif ($direction eq 'from') {
|
||||
return translate($phrase, $toenglish, $req, $ua);
|
||||
}
|
||||
|
||||
my $last_english = $phrase;
|
||||
my $last_lang;
|
||||
my %results = ();
|
||||
my $i = 0;
|
||||
while ($i++ < 7) {
|
||||
last if $results{$phrase}++;
|
||||
$last_lang = $phrase = translate($phrase, $tolang, $req, $ua);
|
||||
last if $results{$phrase}++;
|
||||
$last_english = $phrase = translate($phrase, $toenglish, $req, $ua);
|
||||
}
|
||||
return $last_english;
|
||||
}
|
||||
|
||||
|
||||
sub translate {
|
||||
return '' if $no_babel;
|
||||
my ($phrase, $languagepair, $req, $ua) = @_;
|
||||
|
||||
my $urltext = uri_escape($phrase);
|
||||
$req->content("urltext=$urltext&lp=$languagepair&doit=done");
|
||||
|
||||
my $res = $ua->request($req);
|
||||
|
||||
if ($res->is_success) {
|
||||
my $html = $res->content;
|
||||
# This method subject to change with the whims of Altavista's design
|
||||
# staff.
|
||||
my ($translated) =
|
||||
($html =~ m{<br>
|
||||
\s+
|
||||
<font\ face="arial,\ helvetica">
|
||||
\s*
|
||||
(?:\*\*\s+time\ out\s+\*\*)?
|
||||
\s*
|
||||
([^<]*)
|
||||
}sx);
|
||||
$translated =~ s/\n/ /g;
|
||||
$translated =~ s/\s*$//;
|
||||
return $translated;
|
||||
} else {
|
||||
return ":("; # failure
|
||||
}
|
||||
}
|
||||
|
||||
"Hello. I'm a true value.";
|
||||
1266
mozilla/webtools/mozbot/mozbot.pl
Executable file
1266
mozilla/webtools/mozbot/mozbot.pl
Executable file
File diff suppressed because it is too large
Load Diff
17
mozilla/webtools/mozbot/uuidgen/Makefile
Normal file
17
mozilla/webtools/mozbot/uuidgen/Makefile
Normal file
@@ -0,0 +1,17 @@
|
||||
CFLAGS=-g
|
||||
|
||||
OBJS=md5.o token.o main.o
|
||||
|
||||
all: $(OBJS) uuidgen
|
||||
|
||||
uuidgen: $(OBJS)
|
||||
gcc -o uuidgen $(OBJS)
|
||||
|
||||
md5.o: md5.c md5.h
|
||||
|
||||
token.o: token.c token.h
|
||||
|
||||
main.o: main.c
|
||||
|
||||
clean:
|
||||
rm -f *.o *~ core uuidgen
|
||||
17
mozilla/webtools/mozbot/uuidgen/main.c
Normal file
17
mozilla/webtools/mozbot/uuidgen/main.c
Normal file
@@ -0,0 +1,17 @@
|
||||
/* copyright? hah! it's 10 lines of code! */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "token.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
uuid_state state;
|
||||
uuid_t uuid;
|
||||
char output[1024];
|
||||
|
||||
create_uuid_state(&state);
|
||||
create_token(&state, &uuid);
|
||||
format_token(output, &uuid);
|
||||
|
||||
printf("%s\n", output);
|
||||
|
||||
}
|
||||
263
mozilla/webtools/mozbot/uuidgen/md5.c
Normal file
263
mozilla/webtools/mozbot/uuidgen/md5.c
Normal file
@@ -0,0 +1,263 @@
|
||||
/*
|
||||
* This code implements the MD5 message-digest algorithm.
|
||||
* The algorithm is due to Ron Rivest. This code was
|
||||
* written by Colin Plumb in 1993, no copyright is claimed.
|
||||
* This code is in the public domain; do with it what you wish.
|
||||
*
|
||||
* Equivalent code is available from RSA Data Security, Inc.
|
||||
* This code has been tested against that, and is equivalent,
|
||||
* except that you don't need to include two pages of legalese
|
||||
* with every copy.
|
||||
*
|
||||
* To compute the message digest of a chunk of bytes, declare an
|
||||
* MD5Context structure, pass it to MD5Init, call MD5Update as
|
||||
* needed on buffers full of bytes, and then call MD5Final, which
|
||||
* will fill a supplied 16-byte array with the digest.
|
||||
*/
|
||||
|
||||
/* Brutally hacked by John Walker back from ANSI C to K&R (no
|
||||
prototypes) to maintain the tradition that Netfone will compile
|
||||
with Sun's original "cc". */
|
||||
|
||||
#include <memory.h> /* for memcpy() */
|
||||
#include "md5.h"
|
||||
|
||||
#ifdef sgi
|
||||
#define HIGHFIRST
|
||||
#endif
|
||||
|
||||
#ifdef sun
|
||||
#define HIGHFIRST
|
||||
#endif
|
||||
|
||||
#ifndef HIGHFIRST
|
||||
#define byteReverse(buf, len) /* Nothing */
|
||||
#else
|
||||
/*
|
||||
* Note: this code is harmless on little-endian machines.
|
||||
*/
|
||||
void byteReverse(buf, longs)
|
||||
unsigned char *buf; unsigned longs;
|
||||
{
|
||||
uint32 t;
|
||||
do {
|
||||
t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
|
||||
((unsigned) buf[1] << 8 | buf[0]);
|
||||
*(uint32 *) buf = t;
|
||||
buf += 4;
|
||||
} while (--longs);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
|
||||
* initialization constants.
|
||||
*/
|
||||
void MD5Init(ctx)
|
||||
struct MD5Context *ctx;
|
||||
{
|
||||
ctx->buf[0] = 0x67452301;
|
||||
ctx->buf[1] = 0xefcdab89;
|
||||
ctx->buf[2] = 0x98badcfe;
|
||||
ctx->buf[3] = 0x10325476;
|
||||
|
||||
ctx->bits[0] = 0;
|
||||
ctx->bits[1] = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update context to reflect the concatenation of another buffer full
|
||||
* of bytes.
|
||||
*/
|
||||
void MD5Update(ctx, buf, len)
|
||||
struct MD5Context *ctx; unsigned char *buf; unsigned len;
|
||||
{
|
||||
uint32 t;
|
||||
|
||||
/* Update bitcount */
|
||||
|
||||
t = ctx->bits[0];
|
||||
if ((ctx->bits[0] = t + ((uint32) len << 3)) < t)
|
||||
ctx->bits[1]++; /* Carry from low to high */
|
||||
ctx->bits[1] += len >> 29;
|
||||
|
||||
t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
|
||||
|
||||
/* Handle any leading odd-sized chunks */
|
||||
|
||||
if (t) {
|
||||
unsigned char *p = (unsigned char *) ctx->in + t;
|
||||
|
||||
t = 64 - t;
|
||||
if (len < t) {
|
||||
memcpy(p, buf, len);
|
||||
return;
|
||||
}
|
||||
memcpy(p, buf, t);
|
||||
byteReverse(ctx->in, 16);
|
||||
MD5Transform(ctx->buf, (uint32 *) ctx->in);
|
||||
buf += t;
|
||||
len -= t;
|
||||
}
|
||||
/* Process data in 64-byte chunks */
|
||||
|
||||
while (len >= 64) {
|
||||
memcpy(ctx->in, buf, 64);
|
||||
byteReverse(ctx->in, 16);
|
||||
MD5Transform(ctx->buf, (uint32 *) ctx->in);
|
||||
buf += 64;
|
||||
len -= 64;
|
||||
}
|
||||
|
||||
/* Handle any remaining bytes of data. */
|
||||
|
||||
memcpy(ctx->in, buf, len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Final wrapup - pad to 64-byte boundary with the bit pattern
|
||||
* 1 0* (64-bit count of bits processed, MSB-first)
|
||||
*/
|
||||
void MD5Final(digest, ctx)
|
||||
unsigned char digest[16]; struct MD5Context *ctx;
|
||||
{
|
||||
unsigned count;
|
||||
unsigned char *p;
|
||||
|
||||
/* Compute number of bytes mod 64 */
|
||||
count = (ctx->bits[0] >> 3) & 0x3F;
|
||||
|
||||
/* Set the first char of padding to 0x80. This is safe since there is
|
||||
always at least one byte free */
|
||||
p = ctx->in + count;
|
||||
*p++ = 0x80;
|
||||
|
||||
/* Bytes of padding needed to make 64 bytes */
|
||||
count = 64 - 1 - count;
|
||||
|
||||
/* Pad out to 56 mod 64 */
|
||||
if (count < 8) {
|
||||
/* Two lots of padding: Pad the first block to 64 bytes */
|
||||
memset(p, 0, count);
|
||||
byteReverse(ctx->in, 16);
|
||||
MD5Transform(ctx->buf, (uint32 *) ctx->in);
|
||||
|
||||
/* Now fill the next block with 56 bytes */
|
||||
memset(ctx->in, 0, 56);
|
||||
} else {
|
||||
/* Pad block to 56 bytes */
|
||||
memset(p, 0, count - 8);
|
||||
}
|
||||
byteReverse(ctx->in, 14);
|
||||
|
||||
/* Append length in bits and transform */
|
||||
((uint32 *) ctx->in)[14] = ctx->bits[0];
|
||||
((uint32 *) ctx->in)[15] = ctx->bits[1];
|
||||
|
||||
MD5Transform(ctx->buf, (uint32 *) ctx->in);
|
||||
byteReverse((unsigned char *) ctx->buf, 4);
|
||||
memcpy(digest, ctx->buf, 16);
|
||||
memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
|
||||
}
|
||||
|
||||
|
||||
/* The four core functions - F1 is optimized somewhat */
|
||||
|
||||
/* #define F1(x, y, z) (x & y | ~x & z) */
|
||||
#define F1(x, y, z) (z ^ (x & (y ^ z)))
|
||||
#define F2(x, y, z) F1(z, x, y)
|
||||
#define F3(x, y, z) (x ^ y ^ z)
|
||||
#define F4(x, y, z) (y ^ (x | ~z))
|
||||
|
||||
/* This is the central step in the MD5 algorithm. */
|
||||
#define MD5STEP(f, w, x, y, z, data, s) \
|
||||
( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
|
||||
|
||||
/*
|
||||
* The core of the MD5 algorithm, this alters an existing MD5 hash to
|
||||
* reflect the addition of 16 longwords of new data. MD5Update blocks
|
||||
* the data and converts bytes into longwords for this routine.
|
||||
*/
|
||||
void MD5Transform(buf, in)
|
||||
uint32 buf[4]; uint32 in[16];
|
||||
{
|
||||
register uint32 a, b, c, d;
|
||||
|
||||
a = buf[0];
|
||||
b = buf[1];
|
||||
c = buf[2];
|
||||
d = buf[3];
|
||||
|
||||
MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
|
||||
|
||||
MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
|
||||
|
||||
MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
|
||||
|
||||
MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
|
||||
|
||||
buf[0] += a;
|
||||
buf[1] += b;
|
||||
buf[2] += c;
|
||||
buf[3] += d;
|
||||
}
|
||||
26
mozilla/webtools/mozbot/uuidgen/md5.h
Normal file
26
mozilla/webtools/mozbot/uuidgen/md5.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef MD5_H
|
||||
#define MD5_H
|
||||
|
||||
#ifdef __alpha
|
||||
typedef unsigned int uint32;
|
||||
#else
|
||||
typedef unsigned long uint32;
|
||||
#endif
|
||||
|
||||
struct MD5Context {
|
||||
uint32 buf[4];
|
||||
uint32 bits[2];
|
||||
unsigned char in[64];
|
||||
};
|
||||
|
||||
extern void MD5Init();
|
||||
extern void MD5Update();
|
||||
extern void MD5Final();
|
||||
extern void MD5Transform();
|
||||
|
||||
/*
|
||||
* This is needed to make RSAREF happy on some MS-DOS compilers.
|
||||
*/
|
||||
typedef struct MD5Context MD5_CTX;
|
||||
|
||||
#endif /* !MD5_H */
|
||||
356
mozilla/webtools/mozbot/uuidgen/token.c
Normal file
356
mozilla/webtools/mozbot/uuidgen/token.c
Normal file
@@ -0,0 +1,356 @@
|
||||
/*
|
||||
** Copyright (C) 1998-1999 Greg Stein. All Rights Reserved.
|
||||
**
|
||||
** By using this file, you agree to the terms and conditions set forth in
|
||||
** the LICENSE.html file which can be found at the top level of the mod_dav
|
||||
** distribution or at http://www.webdav.org/mod_dav/license-1.html.
|
||||
**
|
||||
** Contact information:
|
||||
** Greg Stein, PO Box 3151, Redmond, WA, 98073
|
||||
** gstein@lyra.org, http://www.webdav.org/mod_dav/
|
||||
*/
|
||||
|
||||
/*
|
||||
** DAV opaquelocktoken scheme implementation
|
||||
**
|
||||
** Written 5/99 by Keith Wannamaker, wannamak@us.ibm.com
|
||||
** Adapted from ISO/DCE RPC spec and a former Internet Draft
|
||||
** by Leach and Salz:
|
||||
** http://www.ics.uci.edu/pub/ietf/webdav/uuid-guid/draft-leach-uuids-guids-01
|
||||
**
|
||||
** Portions of the code are covered by the following license:
|
||||
**
|
||||
** Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc.
|
||||
** Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. &
|
||||
** Digital Equipment Corporation, Maynard, Mass.
|
||||
** Copyright (c) 1998 Microsoft.
|
||||
** To anyone who acknowledges that this file is provided "AS IS"
|
||||
** without any express or implied warranty: permission to use, copy,
|
||||
** modify, and distribute this file for any purpose is hereby
|
||||
** granted without fee, provided that the above copyright notices and
|
||||
** this notice appears in all source code copies, and that none of
|
||||
** the names of Open Software Foundation, Inc., Hewlett-Packard
|
||||
** Company, or Digital Equipment Corporation be used in advertising
|
||||
** or publicity pertaining to distribution of the software without
|
||||
** specific, written prior permission. Neither Open Software
|
||||
** Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital Equipment
|
||||
** Corporation makes any representations about the suitability of
|
||||
** this software for any purpose.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "md5.h"
|
||||
#include "token.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#endif
|
||||
|
||||
/* set the following to the number of 100ns ticks of the actual resolution of
|
||||
your system's clock */
|
||||
#define UUIDS_PER_TICK 1024
|
||||
|
||||
/* Set this to what your compiler uses for 64 bit data type */
|
||||
#ifdef WIN32
|
||||
#define unsigned64_t unsigned __int64
|
||||
#define I64(C) C
|
||||
#else
|
||||
#define unsigned64_t unsigned long long
|
||||
#define I64(C) C##LL
|
||||
#endif
|
||||
|
||||
typedef unsigned64_t uuid_time_t;
|
||||
|
||||
const uuid_t null_locktoken = {0};
|
||||
|
||||
static void format_uuid_v1(uuid_t * uuid, unsigned16 clockseq, uuid_time_t timestamp, uuid_node_t node);
|
||||
static void get_current_time(uuid_time_t * timestamp);
|
||||
static unsigned16 true_random(void);
|
||||
static void get_pseudo_node_identifier(uuid_node_t *node);
|
||||
static void get_system_time(uuid_time_t *uuid_time);
|
||||
static void get_random_info(unsigned char seed[16]);
|
||||
|
||||
|
||||
/* dav_create_opaquelocktoken - generates a UUID version 1 token.
|
||||
* Clock_sequence and node_address set to pseudo-random
|
||||
* numbers during init.
|
||||
*
|
||||
* Should postpend pid to account for non-seralized creation?
|
||||
*/
|
||||
int create_token(uuid_state *st, uuid_t *u)
|
||||
{
|
||||
uuid_time_t timestamp;
|
||||
|
||||
get_current_time(×tamp);
|
||||
format_uuid_v1(u, st->cs, timestamp, st->node);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* dav_create_uuid_state - seed UUID state with pseudorandom data
|
||||
*/
|
||||
void create_uuid_state(uuid_state *st)
|
||||
{
|
||||
st->cs = true_random();
|
||||
get_pseudo_node_identifier(&st->node);
|
||||
}
|
||||
|
||||
/*
|
||||
* dav_format_opaquelocktoken - generates a text representation
|
||||
* of an opaquelocktoken
|
||||
*/
|
||||
void format_token(char *target, const uuid_t *u)
|
||||
{
|
||||
sprintf(target, "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
u->time_low, u->time_mid, u->time_hi_and_version,
|
||||
u->clock_seq_hi_and_reserved, u->clock_seq_low,
|
||||
u->node[0], u->node[1], u->node[2],
|
||||
u->node[3], u->node[4], u->node[5]);
|
||||
}
|
||||
|
||||
/* convert a pair of hex digits to an integer value [0,255] */
|
||||
static int dav_parse_hexpair(const char *s)
|
||||
{
|
||||
int result;
|
||||
int temp;
|
||||
|
||||
result = s[0] - '0';
|
||||
if (result > 48)
|
||||
result = (result - 39) << 4;
|
||||
else if (result > 16)
|
||||
result = (result - 7) << 4;
|
||||
else
|
||||
result = result << 4;
|
||||
|
||||
temp = s[1] - '0';
|
||||
if (temp > 48)
|
||||
result |= temp - 39;
|
||||
else if (temp > 16)
|
||||
result |= temp - 7;
|
||||
else
|
||||
result |= temp;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* dav_parse_locktoken: Parses string produced from
|
||||
* dav_format_opaquelocktoken back into a uuid_t
|
||||
* structure. On failure, return DAV_IF_ERROR_PARSE,
|
||||
* else DAV_IF_ERROR_NONE.
|
||||
*/
|
||||
int parse_token(const char *char_token, uuid_t *bin_token)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 36; ++i) {
|
||||
char c = char_token[i];
|
||||
if (!isxdigit(c) &&
|
||||
!(c == '-' && (i == 8 || i == 13 || i == 18 || i == 23)))
|
||||
return -1;
|
||||
}
|
||||
if (char_token[36] != '\0')
|
||||
return -1;
|
||||
|
||||
bin_token->time_low =
|
||||
(dav_parse_hexpair(&char_token[0]) << 24) |
|
||||
(dav_parse_hexpair(&char_token[2]) << 16) |
|
||||
(dav_parse_hexpair(&char_token[4]) << 8) |
|
||||
dav_parse_hexpair(&char_token[6]);
|
||||
|
||||
bin_token->time_mid =
|
||||
(dav_parse_hexpair(&char_token[9]) << 8) |
|
||||
dav_parse_hexpair(&char_token[11]);
|
||||
|
||||
bin_token->time_hi_and_version =
|
||||
(dav_parse_hexpair(&char_token[14]) << 8) |
|
||||
dav_parse_hexpair(&char_token[16]);
|
||||
|
||||
bin_token->clock_seq_hi_and_reserved = dav_parse_hexpair(&char_token[19]);
|
||||
bin_token->clock_seq_low = dav_parse_hexpair(&char_token[21]);
|
||||
|
||||
for (i = 6; i--;)
|
||||
bin_token->node[i] = dav_parse_hexpair(&char_token[i*2+24]);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* dav_compare_opaquelocktoken:
|
||||
* < 0 : a < b
|
||||
* == 0 : a = b
|
||||
* > 0 : a > b
|
||||
*/
|
||||
int compare_token(const uuid_t a, const uuid_t b)
|
||||
{
|
||||
return memcmp(&a, &b, sizeof(uuid_t));
|
||||
}
|
||||
|
||||
/* format_uuid_v1 -- make a UUID from the timestamp, clockseq, and node ID */
|
||||
static void format_uuid_v1(uuid_t * uuid, unsigned16 clock_seq,
|
||||
uuid_time_t timestamp, uuid_node_t node)
|
||||
{
|
||||
/* Construct a version 1 uuid with the information we've gathered
|
||||
* plus a few constants. */
|
||||
uuid->time_low = (unsigned long)(timestamp & 0xFFFFFFFF);
|
||||
uuid->time_mid = (unsigned short)((timestamp >> 32) & 0xFFFF);
|
||||
uuid->time_hi_and_version = (unsigned short)((timestamp >> 48) & 0x0FFF);
|
||||
uuid->time_hi_and_version |= (1 << 12);
|
||||
uuid->clock_seq_low = clock_seq & 0xFF;
|
||||
uuid->clock_seq_hi_and_reserved = (clock_seq & 0x3F00) >> 8;
|
||||
uuid->clock_seq_hi_and_reserved |= 0x80;
|
||||
memcpy(&uuid->node, &node, sizeof uuid->node);
|
||||
}
|
||||
|
||||
/* get-current_time -- get time as 60 bit 100ns ticks since whenever.
|
||||
Compensate for the fact that real clock resolution is less than 100ns. */
|
||||
static void get_current_time(uuid_time_t * timestamp)
|
||||
{
|
||||
uuid_time_t time_now;
|
||||
static uuid_time_t time_last;
|
||||
static unsigned16 uuids_this_tick;
|
||||
static int inited = 0;
|
||||
|
||||
if (!inited) {
|
||||
get_system_time(&time_now);
|
||||
uuids_this_tick = UUIDS_PER_TICK;
|
||||
inited = 1;
|
||||
};
|
||||
|
||||
while (1) {
|
||||
get_system_time(&time_now);
|
||||
|
||||
/* if clock reading changed since last UUID generated... */
|
||||
if (time_last != time_now) {
|
||||
/* reset count of uuids gen'd with this clock reading */
|
||||
uuids_this_tick = 0;
|
||||
break;
|
||||
};
|
||||
if (uuids_this_tick < UUIDS_PER_TICK) {
|
||||
uuids_this_tick++;
|
||||
break;
|
||||
}; /* going too fast for our clock; spin */
|
||||
}; /* add the count of uuids to low order bits of the clock reading */
|
||||
|
||||
*timestamp = time_now + uuids_this_tick;
|
||||
}
|
||||
|
||||
/* true_random -- generate a crypto-quality random number.
|
||||
This sample doesn't do that. */
|
||||
static unsigned16 true_random(void)
|
||||
{
|
||||
uuid_time_t time_now;
|
||||
|
||||
get_system_time(&time_now);
|
||||
time_now = time_now/UUIDS_PER_TICK;
|
||||
srand((unsigned int)(((time_now >> 32) ^ time_now)&0xffffffff));
|
||||
|
||||
return rand();
|
||||
}
|
||||
|
||||
/* This sample implementation generates a random node ID *
|
||||
* in lieu of a system dependent call to get IEEE node ID. */
|
||||
static void get_pseudo_node_identifier(uuid_node_t *node)
|
||||
{
|
||||
unsigned char seed[16];
|
||||
|
||||
get_random_info(seed);
|
||||
seed[0] |= 0x80;
|
||||
memcpy(node, seed, sizeof(*node));
|
||||
}
|
||||
|
||||
/* system dependent call to get the current system time.
|
||||
Returned as 100ns ticks since Oct 15, 1582, but resolution may be
|
||||
less than 100ns. */
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
static void get_system_time(uuid_time_t *uuid_time)
|
||||
{
|
||||
ULARGE_INTEGER time;
|
||||
|
||||
GetSystemTimeAsFileTime((FILETIME *)&time);
|
||||
|
||||
/* NT keeps time in FILETIME format which is 100ns ticks since
|
||||
Jan 1, 1601. UUIDs use time in 100ns ticks since Oct 15, 1582.
|
||||
The difference is 17 Days in Oct + 30 (Nov) + 31 (Dec)
|
||||
+ 18 years and 5 leap days. */
|
||||
|
||||
time.QuadPart +=
|
||||
(unsigned __int64) (1000*1000*10) // seconds
|
||||
* (unsigned __int64) (60 * 60 * 24) // days
|
||||
* (unsigned __int64) (17+30+31+365*18+5); // # of days
|
||||
*uuid_time = time.QuadPart;
|
||||
}
|
||||
|
||||
static void get_random_info(unsigned char seed[16])
|
||||
{
|
||||
MD5_CTX c;
|
||||
struct {
|
||||
MEMORYSTATUS m;
|
||||
SYSTEM_INFO s;
|
||||
FILETIME t;
|
||||
LARGE_INTEGER pc;
|
||||
DWORD tc;
|
||||
DWORD l;
|
||||
char hostname[MAX_COMPUTERNAME_LENGTH + 1];
|
||||
|
||||
} r;
|
||||
|
||||
MD5Init(&c); /* memory usage stats */
|
||||
GlobalMemoryStatus(&r.m); /* random system stats */
|
||||
GetSystemInfo(&r.s); /* 100ns resolution (nominally) time of day */
|
||||
GetSystemTimeAsFileTime(&r.t); /* high resolution performance counter */
|
||||
QueryPerformanceCounter(&r.pc); /* milliseconds since last boot */
|
||||
r.tc = GetTickCount();
|
||||
r.l = MAX_COMPUTERNAME_LENGTH + 1;
|
||||
|
||||
GetComputerName(r.hostname, &r.l );
|
||||
MD5Update(&c, (const unsigned char *) &r, sizeof(r));
|
||||
MD5Final(seed, &c);
|
||||
}
|
||||
|
||||
#else /* WIN32 */
|
||||
|
||||
static void get_system_time(uuid_time_t *uuid_time)
|
||||
{
|
||||
struct timeval tp;
|
||||
|
||||
gettimeofday(&tp, (struct timezone *)0);
|
||||
|
||||
/* Offset between UUID formatted times and Unix formatted times.
|
||||
UUID UTC base time is October 15, 1582.
|
||||
Unix base time is January 1, 1970. */
|
||||
*uuid_time = (tp.tv_sec * 10000000) + (tp.tv_usec * 10) +
|
||||
I64(0x01B21DD213814000);
|
||||
}
|
||||
|
||||
static void get_random_info(unsigned char seed[16])
|
||||
{
|
||||
MD5_CTX c;
|
||||
/* Leech & Salz use Linux-specific struct sysinfo;
|
||||
* replace with pid/tid for portability (in the spirit of mod_unique_id) */
|
||||
struct {
|
||||
/* Add thread id here, if applicable, when we get to pthread or apr */
|
||||
pid_t pid;
|
||||
struct timeval t;
|
||||
char hostname[257];
|
||||
|
||||
} r;
|
||||
|
||||
MD5Init(&c);
|
||||
r.pid = getpid();
|
||||
gettimeofday(&r.t, (struct timezone *)0);
|
||||
gethostname(r.hostname, 256);
|
||||
MD5Update(&c, (const unsigned char *)&r, sizeof(r));
|
||||
MD5Final(seed, &c);
|
||||
}
|
||||
|
||||
#endif /* WIN32 */
|
||||
80
mozilla/webtools/mozbot/uuidgen/token.h
Normal file
80
mozilla/webtools/mozbot/uuidgen/token.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
** Copyright (C) 1998-1999 Greg Stein. All Rights Reserved.
|
||||
**
|
||||
** By using this file, you agree to the terms and conditions set forth in
|
||||
** the LICENSE.html file which can be found at the top level of the mod_dav
|
||||
** distribution or at http://www.webdav.org/mod_dav/license-1.html.
|
||||
**
|
||||
** Contact information:
|
||||
** Greg Stein, PO Box 3151, Redmond, WA, 98073
|
||||
** gstein@lyra.org, http://www.webdav.org/mod_dav/
|
||||
*/
|
||||
|
||||
/*
|
||||
** DAV opaquelocktoken scheme implementation
|
||||
**
|
||||
** Written 5/99 by Keith Wannamaker, wannamak@us.ibm.com
|
||||
** Adapted from ISO/DCE RPC spec and a former Internet Draft
|
||||
** by Leach and Salz:
|
||||
** http://www.ics.uci.edu/pub/ietf/webdav/uuid-guid/draft-leach-uuids-guids-01
|
||||
**
|
||||
** Portions of the code are covered by the following license:
|
||||
**
|
||||
** Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc.
|
||||
** Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. &
|
||||
** Digital Equipment Corporation, Maynard, Mass.
|
||||
** Copyright (c) 1998 Microsoft.
|
||||
** To anyone who acknowledges that this file is provided "AS IS"
|
||||
** without any express or implied warranty: permission to use, copy,
|
||||
** modify, and distribute this file for any purpose is hereby
|
||||
** granted without fee, provided that the above copyright notices and
|
||||
** this notice appears in all source code copies, and that none of
|
||||
** the names of Open Software Foundation, Inc., Hewlett-Packard
|
||||
** Company, or Digital Equipment Corporation be used in advertising
|
||||
** or publicity pertaining to distribution of the software without
|
||||
** specific, written prior permission. Neither Open Software
|
||||
** Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital Equipment
|
||||
** Corporation makes any representations about the suitability of
|
||||
** this software for any purpose.
|
||||
*/
|
||||
|
||||
#ifndef _TOKEN_H_
|
||||
#define _TOKEN_H_
|
||||
|
||||
typedef unsigned long unsigned32;
|
||||
typedef unsigned short unsigned16;
|
||||
typedef unsigned char unsigned8;
|
||||
|
||||
typedef struct {
|
||||
char nodeID[6];
|
||||
} uuid_node_t;
|
||||
|
||||
#undef uuid_t
|
||||
|
||||
typedef struct _uuid_t
|
||||
{
|
||||
unsigned32 time_low;
|
||||
unsigned16 time_mid;
|
||||
unsigned16 time_hi_and_version;
|
||||
unsigned8 clock_seq_hi_and_reserved;
|
||||
unsigned8 clock_seq_low;
|
||||
unsigned8 node[6];
|
||||
} uuid_t;
|
||||
|
||||
/* data type for UUID generator persistent state */
|
||||
|
||||
typedef struct {
|
||||
uuid_node_t node; /* saved node ID */
|
||||
unsigned16 cs; /* saved clock sequence */
|
||||
} uuid_state;
|
||||
|
||||
extern const uuid_t null_locktoken;
|
||||
|
||||
/* in dav_opaquelock.c */
|
||||
int create_token(uuid_state *st, uuid_t *u);
|
||||
void create_uuid_state(uuid_state *st);
|
||||
void format_token(char *target, const uuid_t *u);
|
||||
int compare_token(const uuid_t a, const uuid_t b);
|
||||
int parse_token(const char *char_token, uuid_t *bin_token);
|
||||
|
||||
#endif /* _TOKEN_H_ */
|
||||
Reference in New Issue
Block a user