Compare commits
1 Commits
NETSCAPE_7
...
RemoveSill
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b18aea027 |
1
CVSROOT/FilesToNotExport
Normal file
@@ -0,0 +1 @@
|
||||
CVSROOT/history
|
||||
36279
mozilla/CHANGES.html
Normal file
@@ -1,132 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
/*
|
||||
|
||||
This file overrides all option settings in the IDE. It is an attempt to allow all builds
|
||||
to have the same options.
|
||||
|
||||
Note: We can't use ConditionalMacros.h in this file because it will conflict with
|
||||
the PowerPlant precompiled headers.
|
||||
|
||||
*/
|
||||
|
||||
/* warning pragmas */
|
||||
#pragma warn_hidevirtual on
|
||||
#pragma warn_emptydecl on
|
||||
#pragma warn_unusedvar on
|
||||
#pragma warn_extracomma on
|
||||
#pragma warn_illpragma on
|
||||
#pragma warn_possunwant on
|
||||
#pragma warn_unusedarg off /* turned off to reduce warnings */
|
||||
|
||||
#pragma check_header_flags on
|
||||
|
||||
/* Language features that must be the same across libraries... */
|
||||
#pragma enumsalwaysint on
|
||||
#pragma unsigned_char off
|
||||
#pragma exceptions on
|
||||
#pragma bool on
|
||||
#pragma wchar_type on
|
||||
#pragma RTTI on
|
||||
|
||||
|
||||
/* Save as much space as possible with strings... */
|
||||
#pragma pool_strings on
|
||||
#pragma dont_reuse_strings off
|
||||
|
||||
#pragma options align=native
|
||||
#pragma sym on /* Takes no memory. OK in non-debug. */
|
||||
|
||||
|
||||
|
||||
#ifdef powerc /* ...generating PowerPC */
|
||||
#pragma toc_data on
|
||||
#pragma fp_contract on
|
||||
#pragma readonly_strings on
|
||||
|
||||
#ifdef DEBUG
|
||||
#pragma profile off /* Turn this on to profile the application. */
|
||||
/* Look for more details about profiling in nsMacMessagePump.cpp. */
|
||||
#pragma traceback on
|
||||
#pragma global_optimizer off
|
||||
#pragma scheduling off
|
||||
#pragma peephole off
|
||||
#pragma optimize_for_size off
|
||||
#else
|
||||
|
||||
#if TARGET_CARBON
|
||||
#pragma traceback on /* should always be ON for Carbon builds */
|
||||
#else
|
||||
#pragma traceback off /* leave on until the final release, so MacsBug logs are interpretable */
|
||||
#endif
|
||||
|
||||
#pragma global_optimizer on
|
||||
#pragma optimization_level 4
|
||||
#pragma scheduling 603
|
||||
#pragma peephole on
|
||||
#pragma optimize_for_size on
|
||||
|
||||
#pragma opt_strength_reduction on
|
||||
#pragma opt_propagation on
|
||||
#pragma opt_loop_invariants on
|
||||
#pragma opt_lifetimes on
|
||||
#pragma opt_dead_code on
|
||||
#pragma opt_dead_assignments on
|
||||
#pragma opt_common_subs on
|
||||
#endif
|
||||
|
||||
#else /* ...generating 68k */
|
||||
#pragma code68020 on
|
||||
#pragma code68881 off
|
||||
|
||||
/* Far everything... */
|
||||
#pragma far_code
|
||||
#pragma far_data on
|
||||
#pragma far_strings on
|
||||
#pragma far_vtables on
|
||||
|
||||
#pragma fourbyteints on /* 4-byte ints */
|
||||
#pragma IEEEdoubles on /* 8-byte doubles (as required by Java and NSPR) */
|
||||
|
||||
#ifdef DEBUG
|
||||
#pragma macsbug on
|
||||
#pragma oldstyle_symbols off
|
||||
#else
|
||||
#pragma macsbug off
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,5 +0,0 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
IDE_Options.h
|
||||
@@ -1,59 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#error "DonÕt use me!"
|
||||
|
||||
#define OLDROUTINELOCATIONS 0
|
||||
#define XP_MAC 1
|
||||
#define NSPR20 1
|
||||
#define _NO_FAST_STRING_INLINES_ 1
|
||||
#define HAVE_BOOLEAN 1
|
||||
#define NETSCAPE 1
|
||||
#define OTUNIXERRORS 1 /* We want OpenTransport error codes */
|
||||
|
||||
#define OJI 1
|
||||
|
||||
/*
|
||||
This compiles in heap dumping utilities and other good stuff
|
||||
for developers -- maybe we only want it in for a special SDK
|
||||
nspr/java runtime(?):
|
||||
*/
|
||||
#define DEVELOPER_DEBUG 1
|
||||
|
||||
#define MAX(_a,_b) ((_a) < (_b) ? (_b) : (_a))
|
||||
#define MIN(_a,_b) ((_a) < (_b) ? (_a) : (_b))
|
||||
@@ -1,80 +0,0 @@
|
||||
#!perl
|
||||
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 mozilla.org code.
|
||||
#
|
||||
# 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):
|
||||
# Simon Fraser <sfraser@netscape.com>
|
||||
#
|
||||
|
||||
require 5.004;
|
||||
|
||||
use strict;
|
||||
|
||||
use Cwd;
|
||||
use Moz::BuildUtils;
|
||||
use Moz::BuildCore;
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# Where have the build options gone?
|
||||
#
|
||||
# The various build flags have been centralized into one place.
|
||||
# The master list of options is in MozBuildFlags.txt. However,
|
||||
# you should never need to edit that file, or this one.
|
||||
#
|
||||
# To customize what gets built, or where to start the build,
|
||||
# edit the $prefs_file_name file in
|
||||
# System Folder:Preferences:Mozilla build prefs:
|
||||
# Documentation is provided in that file.
|
||||
#-------------------------------------------------------------
|
||||
|
||||
my($prefs_file_name) = "Mozilla opt build prefs";
|
||||
my($config_header_file_name) = ":mozilla:config:mac:DefinesOptions.h";
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# hashes to hold build options
|
||||
#-------------------------------------------------------------
|
||||
my(%build);
|
||||
my(%options);
|
||||
my(%filepaths);
|
||||
my(%optiondefines);
|
||||
|
||||
# Hash of input files for this build. Eventually, there will be
|
||||
# input files for manifests, and projects too.
|
||||
my(%inputfiles) = (
|
||||
"buildflags", "MozillaBuildFlags.txt",
|
||||
"checkoutdata", "MozillaCheckoutList.txt",
|
||||
"buildprogress", "¥ Mozilla opt progress",
|
||||
"buildmodule", "MozillaBuildList.pm",
|
||||
"checkouttime", "Mozilla last checkout"
|
||||
);
|
||||
#-------------------------------------------------------------
|
||||
# end build hashes
|
||||
#-------------------------------------------------------------
|
||||
|
||||
# set the build root directory, which is the the dir above mozilla
|
||||
SetupBuildRootDir(":mozilla:build:mac:build_scripts");
|
||||
|
||||
# Set up all the flags on $main::, like DEBUG, CARBON etc.
|
||||
# Override the defaults using the preferences files.
|
||||
SetupDefaultBuildOptions(0, ":mozilla:dist:viewer:", $config_header_file_name);
|
||||
|
||||
my($do_checkout) = 0;
|
||||
my($do_build) = 1;
|
||||
|
||||
RunBuild($do_checkout, $do_build, \%inputfiles, $prefs_file_name);
|
||||
@@ -1,80 +0,0 @@
|
||||
#!perl
|
||||
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 mozilla.org code.
|
||||
#
|
||||
# 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):
|
||||
# Simon Fraser <sfraser@netscape.com>
|
||||
#
|
||||
|
||||
require 5.004;
|
||||
|
||||
use strict;
|
||||
|
||||
use Cwd;
|
||||
use Moz::BuildUtils;
|
||||
use Moz::BuildCore;
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# Where have the build options gone?
|
||||
#
|
||||
# The various build flags have been centralized into one place.
|
||||
# The master list of options is in MozBuildFlags.txt. However,
|
||||
# you should never need to edit that file, or this one.
|
||||
#
|
||||
# To customize what gets built, or where to start the build,
|
||||
# edit the $prefs_file_name file in
|
||||
# System Folder:Preferences:Mozilla build prefs:
|
||||
# Documentation is provided in that file.
|
||||
#-------------------------------------------------------------
|
||||
|
||||
my($prefs_file_name) = "Mozilla debug build prefs";
|
||||
my($config_header_file_name) = ":mozilla:config:mac:DefinesOptionsDebug.h";
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# hashes to hold build options
|
||||
#-------------------------------------------------------------
|
||||
my(%build);
|
||||
my(%options);
|
||||
my(%filepaths);
|
||||
my(%optiondefines);
|
||||
|
||||
# Hash of input files for this build. Eventually, there will be
|
||||
# input files for manifests, and projects too.
|
||||
my(%inputfiles) = (
|
||||
"buildflags", "MozillaBuildFlags.txt",
|
||||
"checkoutdata", "MozillaCheckoutList.txt",
|
||||
"buildprogress", "¥ Mozilla debug progress",
|
||||
"buildmodule", "MozillaBuildList.pm",
|
||||
"checkouttime", "Mozilla last checkout"
|
||||
);
|
||||
#-------------------------------------------------------------
|
||||
# end build hashes
|
||||
#-------------------------------------------------------------
|
||||
|
||||
# set the build root directory, which is the the dir above mozilla
|
||||
SetupBuildRootDir(":mozilla:build:mac:build_scripts");
|
||||
|
||||
# Set up all the flags on $main::, like DEBUG, CARBON etc.
|
||||
# Override the defaults using the preferences files.
|
||||
SetupDefaultBuildOptions(1, ":mozilla:dist:viewer_debug:", $config_header_file_name);
|
||||
|
||||
my($do_pull) = 0; # overridden by flags and prefs
|
||||
my($do_build) = 1;
|
||||
|
||||
RunBuild($do_pull, $do_build, \%inputfiles, $prefs_file_name);
|
||||
@@ -1,595 +0,0 @@
|
||||
#!perl -w
|
||||
package Moz::BuildCore;
|
||||
|
||||
require 5.004;
|
||||
require Exporter;
|
||||
|
||||
use strict;
|
||||
use vars qw( @ISA @EXPORT );
|
||||
|
||||
# perl includes
|
||||
use Cwd;
|
||||
use POSIX;
|
||||
use Time::Local;
|
||||
use File::Basename;
|
||||
use LWP::Simple;
|
||||
|
||||
# homegrown
|
||||
use Moz::Moz;
|
||||
use Moz::Jar;
|
||||
use Moz::BuildFlags;
|
||||
use Moz::BuildUtils;
|
||||
use Moz::CodeWarriorLib;
|
||||
|
||||
# use MozillaBuildList; # eventually, this should go away, and be replaced by data input
|
||||
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(
|
||||
RunBuild
|
||||
);
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// DoPrebuildCheck
|
||||
#//
|
||||
#// Check the build tools etc before running the build.
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub DoPrebuildCheck()
|
||||
{
|
||||
SanityCheckBuildOptions();
|
||||
|
||||
# launch codewarrior and persist its location. Have to call this before first
|
||||
# call to getCodeWarriorPath().
|
||||
my($ide_path_file) = $main::filepaths{"idepath"};
|
||||
$ide_path_file = full_path_to($ide_path_file);
|
||||
LaunchCodeWarrior($ide_path_file);
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// SanityCheckBuildOptions
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub SanityCheckBuildOptions()
|
||||
{
|
||||
my($bad_options) = 0;
|
||||
|
||||
# Jar options
|
||||
if (!$main::options{chrome_jars} && !$main::options{chrome_files})
|
||||
{
|
||||
print "Warning: Both \$options{chrome_jars} and \$options{chrome_files} are off. You won't get any chrome.\n";
|
||||
$bad_options = 1;
|
||||
}
|
||||
|
||||
if (!$main::options{chrome_jars} && $main::options{use_jars})
|
||||
{
|
||||
print "Warning: \$options{chrome_jars} is off but \$options{use_jars} is on. Your build won't run (expects jars, got files).\n";
|
||||
$bad_options = 1;
|
||||
}
|
||||
|
||||
if (!$main::options{chrome_files} && !$main::options{use_jars})
|
||||
{
|
||||
print "Warning: \$options{chrome_jars} is off but \$options{chrome_files} is on. Your build won't run (expects files, got jars).\n";
|
||||
$bad_options = 1;
|
||||
}
|
||||
|
||||
if ($main::options{ldap_experimental} && !$main::options{ldap})
|
||||
{
|
||||
print "Warning: \$options{ldap_experimental} is on but \$options{ldap} is off. LDAP experimental features will not be built.\n";
|
||||
$bad_options = 1;
|
||||
}
|
||||
|
||||
if ($main::options{wsp} && !$main::options{xmlextras})
|
||||
{
|
||||
print "Warning: \$options{wsp} is on but \$options{xmlextras} is off. wsp will not be built.\n";
|
||||
$bad_options = 1;
|
||||
}
|
||||
|
||||
if ($bad_options) {
|
||||
print "Build will start in 5 seconds. Press command-. to stop\n";
|
||||
|
||||
DelayFor(5);
|
||||
}
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GenBuildSystemInfo
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub GenBuildSystemInfo()
|
||||
{
|
||||
# always rebuild the configuration program.
|
||||
BuildProjectClean(":mozilla:build:mac:tools:BuildSystemInfo:BuildSystemInfo.mcp", "BuildSystemInfo");
|
||||
|
||||
# delete the configuration file.
|
||||
unlink(":mozilla:build:mac:BuildSystemInfo.pm");
|
||||
|
||||
# run the program.
|
||||
system(":mozilla:build:mac:BuildSystemInfo");
|
||||
|
||||
# wait for the file to be created.
|
||||
while (!(-e ":mozilla:build:mac:BuildSystemInfo.pm")) { WaitNextEvent(); }
|
||||
|
||||
# wait for BuildSystemInfo to finish, so that we see correct results.
|
||||
while (IsProcessRunning("BuildSystemInfo")) { WaitNextEvent(); }
|
||||
|
||||
# now, evaluate the contents of the file.
|
||||
open(F, ":mozilla:build:mac:BuildSystemInfo.pm");
|
||||
while (<F>) { eval; }
|
||||
close(F);
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// Make library aliases
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub MakeLibAliases()
|
||||
{
|
||||
my($dist_dir) = GetBinDirectory();
|
||||
|
||||
#// ProfilerLib
|
||||
if ($main::PROFILE)
|
||||
{
|
||||
my($profilerlibpath) = Moz::CodeWarriorLib::getCodeWarriorPath("MacOS Support:Profiler:Profiler Common:ProfilerLib");
|
||||
MakeAlias("$profilerlibpath", "$dist_dir"."Essential Files:");
|
||||
}
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// ConfigureBuildSystem
|
||||
#//
|
||||
#// defines some build-system configuration variables.
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub ConfigureBuildSystem()
|
||||
{
|
||||
#// In the future, we may want to do configurations based on the actual build system itself.
|
||||
#// GenBuildSystemInfo();
|
||||
|
||||
#// For now, if we discover a newer header file than existed in Universal Interfaces 3.2,
|
||||
#// we'll assume that 3.3 or later is in use.
|
||||
my($universal_interfaces) = Moz::CodeWarriorLib::getCodeWarriorPath("MacOS Support:Universal:Interfaces:CIncludes:");
|
||||
if (-e ($universal_interfaces . "ControlDefinitions.h")) {
|
||||
$main::UNIVERSAL_INTERFACES_VERSION = 0x0330;
|
||||
}
|
||||
|
||||
#// Rename IC SDK folder in the Mac OS Support folder
|
||||
my($ic_sdk_folder) = Moz::CodeWarriorLib::getCodeWarriorPath("MacOS Support:ICProgKit2.0.2");
|
||||
if( -e $ic_sdk_folder)
|
||||
{
|
||||
my($new_ic_folder_name) = Moz::CodeWarriorLib::getCodeWarriorPath("MacOS Support:(ICProgKit2.0.2)");
|
||||
rename ($ic_sdk_folder, $new_ic_folder_name);
|
||||
# note that CodeWarrior doesn't descend into folders with () the name
|
||||
print "Mozilla no longer needs the Internet Config SDK to build:\n Renaming the 'ICProgKit2.0.2' folder to '(ICProgKit2.0.2)'\n";
|
||||
}
|
||||
|
||||
printf("UNIVERSAL_INTERFACES_VERSION = 0x%04X\n", $main::UNIVERSAL_INTERFACES_VERSION);
|
||||
|
||||
# alias required CodeWarrior libs into the Essential Files folder (only the Profiler lib now)
|
||||
MakeLibAliases();
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// CheckOutModule. Takes variable number of args; first two are required
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub CheckOutModule($$$$)
|
||||
{
|
||||
my($session, $module, $revision, $date) = @_;
|
||||
|
||||
my($result) = $session->checkout($module, $revision, $date);
|
||||
|
||||
# result of 1 is success
|
||||
if ($result) { return; }
|
||||
|
||||
my($checkout_err) = $session->getLastError();
|
||||
if ($checkout_err == 708) {
|
||||
die "Error: Checkout was cancelled.\n";
|
||||
} elsif ($checkout_err == 911) {
|
||||
die "Error: CVS session settings are incorrect. Check your password, and the CVS root settings.\n";
|
||||
} elsif ($checkout_err == 703) {
|
||||
die "Error: CVS checkout failed. Unknown module, unknown tag, bad username, or other CVS error.\n";
|
||||
} elsif ($checkout_err == 711) {
|
||||
print "Checkout of '$module' failed.\n";
|
||||
}
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getScriptFolder
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getScriptFolder()
|
||||
{
|
||||
return dirname($0);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getScriptFolder
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub get_url_contents($)
|
||||
{
|
||||
my($url) = @_;
|
||||
|
||||
my($url_contents) = LWP::Simple::get($url);
|
||||
$url_contents =~ s/\r\n/\n/g; # normalize linebreaks
|
||||
$url_contents =~ s/\r/\n/g; # normalize linebreaks
|
||||
return $url_contents;
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// get_files_from_content
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub uniq
|
||||
{
|
||||
my $lastval;
|
||||
grep(($_ ne $lastval, $lastval = $_)[$[], @_);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// get_files_from_content
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub get_files_from_content($)
|
||||
{
|
||||
my($content) = @_;
|
||||
|
||||
my(@jscalls) = grep (/return js_file_menu[^{]*/, split(/\n/, $content));
|
||||
my $i;
|
||||
|
||||
for ($i = 0; $i < @jscalls ; $i++)
|
||||
{
|
||||
$jscalls[$i] =~ s/.*\(|\).*//g;
|
||||
my(@callparams) = split(/,/, $jscalls[$i]);
|
||||
my ($repos, $dir, $file, $rev) = grep(s/['\s]//g, @callparams);
|
||||
$jscalls[$i] = "$dir/$file";
|
||||
}
|
||||
|
||||
&uniq(sort(@jscalls));
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getLastUpdateTime
|
||||
#//
|
||||
#// Get the last time we updated. Return 0 on failure
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getLastUpdateTime($)
|
||||
{
|
||||
my($timestamp_file) = @_;
|
||||
|
||||
my($time_string);
|
||||
|
||||
local(*TIMESTAMP_FILE);
|
||||
unless (open(TIMESTAMP_FILE, "< $timestamp_file")) { return 0; }
|
||||
|
||||
while (<TIMESTAMP_FILE>)
|
||||
{
|
||||
my($line) = $_;
|
||||
chomp($line);
|
||||
|
||||
# ignore comments and empty lines
|
||||
if ($line =~ /^\#/ || $line =~ /^\s*$/) {
|
||||
next;
|
||||
}
|
||||
|
||||
$time_string = $line;
|
||||
}
|
||||
|
||||
# get the epoch seconds
|
||||
my($last_update_secs) = $time_string;
|
||||
$last_update_secs =~ s/\s#.+$//;
|
||||
|
||||
print "FAST_UPDATE found that you last updated at ".localtime($last_update_secs)."\n";
|
||||
|
||||
# how long ago was this, in hours?
|
||||
my($gm_now) = time();
|
||||
my($update_hours) = 1 + ceil(($gm_now - $last_update_secs) / (60 * 60));
|
||||
|
||||
return $update_hours;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// saveCheckoutTimestamp
|
||||
#//
|
||||
#// Create a file on disk containing the current time. Param is time(), which is an Epoch seconds
|
||||
#// (and therefore in GMT).
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub saveCheckoutTimestamp($$)
|
||||
{
|
||||
my($gm_secs, $timestamp_file) = @_;
|
||||
|
||||
local(*TIMESTAMP_FILE);
|
||||
open(TIMESTAMP_FILE, ">$timestamp_file") || die "Failed to open $timestamp_file\n";
|
||||
print(TIMESTAMP_FILE "# time of last checkout or update, in GMT. Used by FAST_UPDATE\n");
|
||||
print(TIMESTAMP_FILE "$gm_secs \# around ".localtime()." local time\n");
|
||||
close(TIMESTAMP_FILE);
|
||||
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// FastUpdate
|
||||
#//
|
||||
#// Use Bonsai url data to update only those dirs which have new files
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub FastUpdate($$)
|
||||
{
|
||||
my($modules, $timestamp_file) = @_; # list of modules to check out
|
||||
|
||||
my($num_hours) = getLastUpdateTime($timestamp_file);
|
||||
if ($num_hours == 0 || $num_hours > 170) {
|
||||
print "Can't fast_update; last update was too long ago, or never. Doing normal checkout.\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
print "Doing fast update, pulling files changed in the last $num_hours hours\n";
|
||||
|
||||
my($cvsfile) = AskAndPersistFile($main::filepaths{"sessionpath"});
|
||||
my($session) = Moz::MacCVS->new( $cvsfile );
|
||||
unless (defined($session)) { die "Error: Checkout aborted. Cannot create session file: $session" }
|
||||
|
||||
# activate MacCVS
|
||||
ActivateApplication('Mcvs');
|
||||
|
||||
my($checkout_start_time) = time();
|
||||
|
||||
#print "Time now is $checkout_start_time ($checkout_start_time + 0)\n";
|
||||
|
||||
my($this_co);
|
||||
foreach $this_co (@$modules)
|
||||
{
|
||||
my($module, $revision, $date) = ($this_co->[0], $this_co->[1], $this_co->[2]);
|
||||
|
||||
# assume that things pulled by date wont change
|
||||
if ($date ne "") {
|
||||
print "$module is pulled by date, so ignoring in FastUpdate.\n";
|
||||
next;
|
||||
}
|
||||
|
||||
my($search_type) = "hours";
|
||||
my($min_date) = "";
|
||||
my($max_date) = "";
|
||||
my($url) = "http://bonsai.mozilla.org/cvsquery.cgi?treeid=default&module=${module}&branch=${revision}&branchtype=match&dir=&file=&filetype=match&who=&whotype=match&sortby=Date&hours=${num_hours}&date=${search_type}&mindate=${min_date}&maxdate=${max_date}&cvsroot=%2Fcvsroot";
|
||||
|
||||
if ($revision eq "") {
|
||||
print "Getting list of checkins to $module from Bonsai...\n";
|
||||
} else {
|
||||
print "Getting list of checkins to $module on branch $revision from Bonsai...\n";
|
||||
}
|
||||
my(@files) = &get_files_from_content(&get_url_contents($url));
|
||||
|
||||
if ($#files > 0)
|
||||
{
|
||||
my(@cvs_co_list);
|
||||
|
||||
my($co_file);
|
||||
foreach $co_file (@files)
|
||||
{
|
||||
print "Updating $co_file\n";
|
||||
push(@cvs_co_list, $co_file);
|
||||
}
|
||||
|
||||
my($result) = $session->update($revision, \@cvs_co_list);
|
||||
# result of 1 is success
|
||||
if (!$result) { die "Error: Fast update failed\n"; }
|
||||
} else {
|
||||
print "No files in this module changed\n";
|
||||
}
|
||||
}
|
||||
|
||||
saveCheckoutTimestamp($checkout_start_time, $timestamp_file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// Checkout
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub CheckoutModules($$$)
|
||||
{
|
||||
my($modules, $pull_date, $timestamp_file) = @_; # list of modules to check out
|
||||
|
||||
my($start_time) = TimeStart();
|
||||
|
||||
# assertRightDirectory();
|
||||
my($cvsfile) = AskAndPersistFile($main::filepaths{"sessionpath"});
|
||||
my($session) = Moz::MacCVS->new( $cvsfile );
|
||||
unless (defined($session)) { die "Error: Checkout aborted. Cannot create session file: $session" }
|
||||
|
||||
my($checkout_start_time) = time();
|
||||
|
||||
# activate MacCVS
|
||||
ActivateApplication('Mcvs');
|
||||
|
||||
my($this_co);
|
||||
foreach $this_co (@$modules)
|
||||
{
|
||||
my($module, $revision, $date) = ($this_co->[0], $this_co->[1], $this_co->[2]);
|
||||
if ($date eq "") {
|
||||
$date = $pull_date;
|
||||
}
|
||||
CheckOutModule($session, $module, $revision, $date);
|
||||
# print "Checking out $module with ref $revision, date $date\n";
|
||||
}
|
||||
|
||||
saveCheckoutTimestamp($checkout_start_time, $timestamp_file);
|
||||
TimeEnd($start_time, "Checkout");
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// ReadCheckoutModulesFile
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub ReadCheckoutModulesFile($$)
|
||||
{
|
||||
my($modules_file, $co_list) = @_;
|
||||
|
||||
my($checkout_file) = getScriptFolder().":".$modules_file;
|
||||
local(*CHECKOUT_FILE);
|
||||
open(CHECKOUT_FILE, "< $checkout_file") || die "Error: failed to open checkout list $checkout_file\n";
|
||||
while (<CHECKOUT_FILE>)
|
||||
{
|
||||
my($line) = $_;
|
||||
chomp($line);
|
||||
|
||||
# ignore comments and empty lines
|
||||
if ($line =~ /^\#/ || $line =~ /^\s*$/) {
|
||||
next;
|
||||
}
|
||||
|
||||
my(@cvs_co) = ["", "", ""];
|
||||
|
||||
my($module, $revision, $date) = (0, 1, 2);
|
||||
|
||||
if ($line =~ /\s*([^#,\s]+)\s*\,\s*([^#,\s]+)\s*\,\s*([^#]+)/)
|
||||
{
|
||||
@cvs_co[$module] = $1;
|
||||
@cvs_co[$revision] = $2;
|
||||
@cvs_co[$date] = $3;
|
||||
}
|
||||
elsif ($line =~ /\s*([^#,\s]+)\s*\,\s*([^#,\s]+)\s*(#.+)?/)
|
||||
{
|
||||
@cvs_co[$module] = $1;
|
||||
@cvs_co[$revision] = $2;
|
||||
}
|
||||
elsif ($line =~ /\s*([^#,\s]+)\s*\,\s*,\s*([^#,]+)/)
|
||||
{
|
||||
@cvs_co[$module] = $1;
|
||||
@cvs_co[$date] = $2;
|
||||
}
|
||||
elsif ($line =~ /\s*([^#,\s]+)/)
|
||||
{
|
||||
@cvs_co[$module] = $1;
|
||||
}
|
||||
else
|
||||
{
|
||||
die "Error: unrecognized line '$line' in $modules_file\n";
|
||||
}
|
||||
|
||||
# strip surrounding space from date
|
||||
@cvs_co[$date] =~ s/^\s*|\s*$//g;
|
||||
|
||||
# print "Going to check out '@cvs_co[$module]', '@cvs_co[$revision]', '@cvs_co[$date]'\n";
|
||||
push(@$co_list, \@cvs_co);
|
||||
}
|
||||
|
||||
close(CHECKOUT_FILE);
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// PullFromCVS
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub PullFromCVS($$)
|
||||
{
|
||||
unless ( $main::build{pull} ) { return; }
|
||||
|
||||
my($modules_file, $timestamp_file) = @_;
|
||||
|
||||
StartBuildModule("pull");
|
||||
|
||||
my(@cvs_co_list);
|
||||
ReadCheckoutModulesFile($modules_file, \@cvs_co_list);
|
||||
|
||||
if ($main::FAST_UPDATE && $main::options{pull_by_date})
|
||||
{
|
||||
die "Error: you can't use FAST_UPDATE if you are pulling by date.\n";
|
||||
}
|
||||
|
||||
my($did_fast_update) = $main::FAST_UPDATE && FastUpdate(\@cvs_co_list, $timestamp_file);
|
||||
if (!$did_fast_update)
|
||||
{
|
||||
my($pull_date) = "";
|
||||
if ($main::options{pull_by_date})
|
||||
{
|
||||
# acceptable CVS date formats are (in local time):
|
||||
# ISO8601 (e.g. "1972-09-24 20:05") and Internet (e.g. "24 Sep 1972 20:05").
|
||||
# Perl's localtime() string format also seems to work.
|
||||
$pull_date = localtime().""; # force string interp.
|
||||
print "Pulling by date $pull_date\n";
|
||||
}
|
||||
|
||||
CheckoutModules(\@cvs_co_list, $pull_date, $timestamp_file);
|
||||
}
|
||||
|
||||
EndBuildModule("pull");
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// RunBuild
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub RunBuild($$$$)
|
||||
{
|
||||
my($do_pull, $do_build, $input_files, $build_prefs) = @_;
|
||||
|
||||
InitBuildProgress($input_files->{"buildprogress"});
|
||||
|
||||
# if we are pulling, we probably want to do a full build, so clear the build progress
|
||||
if ($do_pull) {
|
||||
ClearBuildProgress();
|
||||
}
|
||||
|
||||
# read local prefs, and the build progress file, and set flags to say what to build
|
||||
SetupBuildParams(\%main::build,
|
||||
\%main::options,
|
||||
\%main::optiondefines,
|
||||
\%main::filepaths,
|
||||
$input_files->{"buildflags"},
|
||||
$build_prefs);
|
||||
|
||||
# If we were told to pull, make sure we do, overriding prefs etc.
|
||||
if ($do_pull)
|
||||
{
|
||||
$main::build{"pull"} = 1;
|
||||
}
|
||||
|
||||
# transfer this flag
|
||||
$CodeWarriorLib::CLOSE_PROJECTS_FIRST = $main::CLOSE_PROJECTS_FIRST;
|
||||
|
||||
# setup the build log
|
||||
SetupBuildLog($main::filepaths{"buildlogfilepath"}, $main::USE_TIMESTAMPED_LOGS);
|
||||
StopForErrors();
|
||||
|
||||
if ($main::LOG_TO_FILE) {
|
||||
RedirectOutputToFile($main::filepaths{"scriptlogfilepath"});
|
||||
}
|
||||
|
||||
# run a pre-build check to see that the tools etc are in order
|
||||
DoPrebuildCheck();
|
||||
|
||||
# do the pull
|
||||
PullFromCVS($input_files->{"checkoutdata"}, $input_files->{"checkouttime"});
|
||||
|
||||
unless ($do_build) { return; }
|
||||
|
||||
my($build_start) = TimeStart();
|
||||
|
||||
# check the build environment
|
||||
ConfigureBuildSystem();
|
||||
|
||||
# here we load and call methods in the build module indirectly.
|
||||
# we have to use indirection because the build module can be named
|
||||
# differently for different builds.
|
||||
chdir(dirname($0)); # change to the script dir
|
||||
my($build_module) = $input_files->{"buildmodule"};
|
||||
# load the build module
|
||||
require $build_module;
|
||||
{ # scope for no strict 'refs'
|
||||
no strict 'refs';
|
||||
|
||||
my($package_name) = $build_module;
|
||||
$package_name =~ s/\.pm$//;
|
||||
|
||||
chdir($main::MOZ_SRC);
|
||||
&{$package_name."::BuildDist"}();
|
||||
|
||||
chdir($main::MOZ_SRC);
|
||||
&{$package_name."::BuildProjects"}();
|
||||
}
|
||||
|
||||
# the build finished, so clear the build progress state
|
||||
ClearBuildProgress();
|
||||
|
||||
TimeEnd($build_start, "Build");
|
||||
print "Build complete\n";
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -1,425 +0,0 @@
|
||||
#!perl -w
|
||||
package Moz::BuildFlags;
|
||||
|
||||
require 5.004;
|
||||
require Exporter;
|
||||
|
||||
# Package that attempts to read a file from the Preferences folder,
|
||||
# and get build settings out of it
|
||||
|
||||
use strict;
|
||||
use Exporter;
|
||||
|
||||
use Cwd;
|
||||
use File::Basename;
|
||||
|
||||
use Moz::Moz;
|
||||
use Moz::Prefs;
|
||||
|
||||
use vars qw(@ISA @EXPORT);
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(
|
||||
SetupBuildParams
|
||||
InitBuildProgress
|
||||
WriteBuildProgress
|
||||
ClearBuildProgress
|
||||
ReadBuildProgress
|
||||
);
|
||||
|
||||
|
||||
my(@build_flags);
|
||||
my(@options_flags);
|
||||
my(@filepath_flags);
|
||||
|
||||
my(%arrays_list) = (
|
||||
"build_flags", \@build_flags,
|
||||
"options_flags", \@options_flags,
|
||||
"filepath_flags", \@filepath_flags
|
||||
);
|
||||
|
||||
my($progress_file) = "¥ÊBuild progress";
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# appendArrayFlag
|
||||
#
|
||||
# Set a flag in the array
|
||||
#-------------------------------------------------------------------------------
|
||||
sub appendArrayFlag(@)
|
||||
{
|
||||
my($array_name) = shift;
|
||||
my($setting) = shift;
|
||||
my($value) = shift;
|
||||
|
||||
my(@optional_values);
|
||||
foreach (@_) {
|
||||
push(@optional_values, $_);
|
||||
}
|
||||
|
||||
my(@this_flag) = [$setting, $value, @optional_values];
|
||||
my($flags_array) = $arrays_list{$array_name};
|
||||
if ($flags_array)
|
||||
{
|
||||
push(@{$flags_array}, @this_flag) || die "Failed to append\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
die "Error: unknown build flags array $array_name\n";
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# readFlagsFile
|
||||
#
|
||||
# Read the file of build flags from disk. File path is relative to the
|
||||
# script directory.
|
||||
#-------------------------------------------------------------------------------
|
||||
sub readFlagsFile($)
|
||||
{
|
||||
my($flags_file) = @_;
|
||||
|
||||
my($file_path) = $0;
|
||||
$file_path =~ s/[^:]+$/$flags_file/;
|
||||
|
||||
print "Reading build flags from '$file_path'\n";
|
||||
|
||||
local(*FLAGS_FILE);
|
||||
open(FLAGS_FILE, "< $file_path") || die "Error: failed to open flags file $file_path\n";
|
||||
|
||||
my($cur_array) = "";
|
||||
|
||||
while(<FLAGS_FILE>)
|
||||
{
|
||||
my($line) = $_;
|
||||
chomp($line);
|
||||
|
||||
# ignore comments and empty lines
|
||||
if ($line =~ /^\#/ || $line =~ /^\s*$/) {
|
||||
next;
|
||||
}
|
||||
|
||||
# 1-word line, probably array name
|
||||
if ($line =~ /^([^#\s]+)\s*$/)
|
||||
{
|
||||
$cur_array = $1;
|
||||
next;
|
||||
}
|
||||
elsif ($line =~ /^([^#\s]+)\s+\"(.+)\"(\s+#.+)?$/) # quoted option, possible comment
|
||||
{
|
||||
my($flag) = $1;
|
||||
my($setting) = $2;
|
||||
|
||||
appendArrayFlag($cur_array, $flag, $setting);
|
||||
}
|
||||
elsif ($line =~ /^([^#\s]+)((\s+[^#\s]+)+)(\s+#.+)?$/) # multiple word line, possible comment
|
||||
{
|
||||
my($flag) = $1;
|
||||
|
||||
appendArrayFlag($cur_array, $flag, split(' ', $2));
|
||||
}
|
||||
else
|
||||
{
|
||||
die "Error: unknown build flag at '$line'\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
close(FLAGS_FILE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# flagsArrayToHash
|
||||
#
|
||||
# Utility routine to migrate flag from a 2D array to a hash, where
|
||||
# item[n][0] is the hash entry name, and item[n][1] is the hash entry value.
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
sub flagsArrayToHash($$)
|
||||
{
|
||||
my($src_array, $dest_hash) = @_;
|
||||
|
||||
my($item);
|
||||
foreach $item (@$src_array)
|
||||
{
|
||||
$dest_hash->{$item->[0]} = $item->[1];
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------
|
||||
# printHash
|
||||
#
|
||||
# Utility routine to print a hash
|
||||
#-----------------------------------------------
|
||||
sub printHash($)
|
||||
{
|
||||
my($hash_ref) = @_;
|
||||
|
||||
print "Printing hash:\n";
|
||||
|
||||
my($key, $value);
|
||||
|
||||
while (($key, $value) = each (%$hash_ref))
|
||||
{
|
||||
print " $key $value\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-----------------------------------------------
|
||||
# printBuildArray
|
||||
#
|
||||
# Utility routine to print a 2D array
|
||||
#-----------------------------------------------
|
||||
sub printBuildArray($)
|
||||
{
|
||||
my($build_array) = @_;
|
||||
|
||||
my($entry);
|
||||
foreach $entry (@$build_array)
|
||||
{
|
||||
print "$entry->[0] = $entry->[1]\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# SetBuildFlags
|
||||
#-------------------------------------------------------------------------------
|
||||
sub SetBuildFlags($)
|
||||
{
|
||||
my($build) = @_;
|
||||
|
||||
flagsArrayToHash(\@build_flags, $build);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# SetBuildOptions
|
||||
#-------------------------------------------------------------------------------
|
||||
sub SetBuildOptions($)
|
||||
{
|
||||
my($options) = @_;
|
||||
|
||||
flagsArrayToHash(\@options_flags, $options);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# SetFilepathFlags
|
||||
#-------------------------------------------------------------------------------
|
||||
sub SetFilepathFlags($)
|
||||
{
|
||||
my($filepath) = @_;
|
||||
|
||||
flagsArrayToHash(\@filepath_flags, $filepath);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# SetOptionDefines
|
||||
#-------------------------------------------------------------------------------
|
||||
sub SetOptionDefines($)
|
||||
{
|
||||
my($optiondefines) = @_;
|
||||
|
||||
foreach my $entry (@options_flags)
|
||||
{
|
||||
if (defined($entry->[2])) {
|
||||
$optiondefines->{$entry->[0]}{$entry->[2]} = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# PropagateAllFlags
|
||||
#-------------------------------------------------------------------------------
|
||||
sub PropagateAllFlags($)
|
||||
{
|
||||
my($build_array) = @_;
|
||||
|
||||
# if "all" is set, set all the flags to 1
|
||||
unless ($build_array->[0][0] eq "all") { die "Error: 'all' must come first in the flags array\n"; }
|
||||
|
||||
if ($build_array->[0][1] == 1)
|
||||
{
|
||||
my($index);
|
||||
foreach $index (@$build_array)
|
||||
{
|
||||
$index->[1] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// _getBuildProgressFile
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub _getBuildProgressFile()
|
||||
{
|
||||
return $progress_file;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// setBuildProgressStart
|
||||
#//
|
||||
#// This automagically sets $build{"all"} to 0
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub setBuildProgressStart($$)
|
||||
{
|
||||
my($build_array, $name) = @_;
|
||||
|
||||
my($index);
|
||||
foreach $index (@$build_array)
|
||||
{
|
||||
$index->[1] = 0;
|
||||
if ($index->[0] eq $name) {
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
print "Building from module after $name, as specified by build progress\n";
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// InitBuildProgress
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub InitBuildProgress($)
|
||||
{
|
||||
my($prog_file) = @_;
|
||||
if ($prog_file ne "") {
|
||||
$progress_file = full_path_to($prog_file);
|
||||
print "Writing build progress to $progress_file\n";
|
||||
}
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// WriteBuildProgress
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub WriteBuildProgress($)
|
||||
{
|
||||
my($module_built) = @_;
|
||||
|
||||
my($progress_file) = _getBuildProgressFile();
|
||||
|
||||
if ($progress_file ne "")
|
||||
{
|
||||
open(PROGRESS_FILE, ">>$progress_file") || die "Failed to open $progress_file\n";
|
||||
print(PROGRESS_FILE "$module_built\n");
|
||||
close(PROGRESS_FILE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// ClearBuildProgress
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub ClearBuildProgress()
|
||||
{
|
||||
my($progress_file) = _getBuildProgressFile();
|
||||
if ($progress_file ne "") {
|
||||
unlink $progress_file;
|
||||
}
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// WipeBuildProgress
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub WipeBuildProgress()
|
||||
{
|
||||
print "Ignoring build progress\n";
|
||||
ClearBuildProgress();
|
||||
$progress_file = "";
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// ReadBuildProgress
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub ReadBuildProgress($)
|
||||
{
|
||||
my($build_array) = @_;
|
||||
my($progress_file) = _getBuildProgressFile();
|
||||
|
||||
my($last_module);
|
||||
|
||||
if (open(PROGRESS_FILE, "< $progress_file"))
|
||||
{
|
||||
print "Getting build progress from $progress_file\n";
|
||||
|
||||
while (<PROGRESS_FILE>)
|
||||
{
|
||||
my($line) = $_;
|
||||
chomp($line);
|
||||
$last_module = $line;
|
||||
}
|
||||
|
||||
close(PROGRESS_FILE);
|
||||
}
|
||||
|
||||
if ($last_module)
|
||||
{
|
||||
setBuildProgressStart($build_array, $last_module);
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# clearOldBuildSettings
|
||||
#-------------------------------------------------------------------------------
|
||||
sub clearOldBuildSettings($$$$)
|
||||
{
|
||||
my($build, $options, $optiondefines, $filepaths) = @_;
|
||||
|
||||
# empty the arrays in case we're being called twice
|
||||
@build_flags = ();
|
||||
@options_flags = ();
|
||||
@filepath_flags = ();
|
||||
|
||||
# and empty the hashes
|
||||
%$build = ();
|
||||
%$options = ();
|
||||
%$optiondefines = ();
|
||||
%$filepaths = ();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# SetupBuildParams
|
||||
#-------------------------------------------------------------------------------
|
||||
sub SetupBuildParams($$$$$$)
|
||||
{
|
||||
my($build, $options, $optiondefines, $filepaths, $flags_file, $prefs_file) = @_;
|
||||
|
||||
# Empty the hashes and arrays, to wipe out any stale data.
|
||||
# Needed because these structures persist across two build scripts
|
||||
# called using 'do' from a parent script.
|
||||
clearOldBuildSettings($build, $options, $optiondefines, $filepaths);
|
||||
|
||||
# Read from the flags file, which sets up the various arrays
|
||||
readFlagsFile($flags_file);
|
||||
|
||||
# If 'all' is set in the build array, propagate that to all entries
|
||||
PropagateAllFlags(\@build_flags);
|
||||
|
||||
# read the user pref file, that can change values in the array
|
||||
ReadMozUserPrefs($prefs_file, \@build_flags, \@options_flags, \@filepath_flags);
|
||||
|
||||
# If build progress exists, this clears flags in the array up to a certain point
|
||||
if ($main::USE_BUILD_PROGRESS) {
|
||||
ReadBuildProgress(\@build_flags);
|
||||
} else {
|
||||
WipeBuildProgress();
|
||||
}
|
||||
|
||||
# printBuildArray(\@build_flags);
|
||||
# printBuildArray(\@options_flags);
|
||||
|
||||
SetBuildFlags($build);
|
||||
SetBuildOptions($options);
|
||||
SetOptionDefines($optiondefines);
|
||||
SetFilepathFlags($filepaths);
|
||||
|
||||
# printHash($build);
|
||||
# printHash($options);
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
@@ -1,786 +0,0 @@
|
||||
|
||||
package Moz::BuildUtils;
|
||||
|
||||
require 5.004;
|
||||
require Exporter;
|
||||
|
||||
# Package that contains build util functions specific to the Mozilla build
|
||||
# process.
|
||||
|
||||
use strict;
|
||||
use Exporter;
|
||||
|
||||
use Cwd;
|
||||
use File::Path;
|
||||
use File::Basename;
|
||||
|
||||
use Mac::Events;
|
||||
use Mac::StandardFile;
|
||||
|
||||
use Moz::Moz;
|
||||
use Moz::BuildFlags;
|
||||
use Moz::MacCVS;
|
||||
#use Moz::ProjectXML; #optional; required for static build only
|
||||
|
||||
use vars qw(@ISA @EXPORT);
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(
|
||||
SetupDefaultBuildOptions
|
||||
SetupBuildRootDir
|
||||
StartBuildModule
|
||||
EndBuildModule
|
||||
GetBinDirectory
|
||||
BuildOneProjectWithOutput
|
||||
BuildOneProject
|
||||
BuildProject
|
||||
BuildProjectClean
|
||||
BuildIDLProject
|
||||
BuildFolderResourceAliases
|
||||
AskAndPersistFile
|
||||
DelayFor
|
||||
TimeStart
|
||||
TimeEnd
|
||||
EmptyTree
|
||||
SetupBuildLog
|
||||
SetBuildNumber
|
||||
SetTimeBomb
|
||||
UpdateConfigHeader
|
||||
);
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// SetupDefaultBuildOptions
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub SetupDefaultBuildOptions($$$)
|
||||
{
|
||||
my($debug, $bin_dir, $config_header_file_name) = @_;
|
||||
|
||||
# Here we set up defaults for the various build flags.
|
||||
# If you want to override any of these, it's best to do
|
||||
# so via the relevant preferences file, which lives in
|
||||
# System Folder:Preferences:Mozilla build prefs:{build prefs file}.
|
||||
# For the name of the prefs file, see the .pl script that you
|
||||
# run to start this build. The prefs files are created when
|
||||
# you run the build, and contain some documentation.
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# configuration variables that globally affect what is built
|
||||
#-------------------------------------------------------------
|
||||
$main::DEBUG = $debug;
|
||||
$main::PROFILE = 0;
|
||||
$main::RUNTIME = 0; # turn on to just build runtime support and NSPR projects
|
||||
$main::GC_LEAK_DETECTOR = 0; # turn on to use GC leak detection
|
||||
$main::MOZILLA_OFFICIAL = 0; # generate build number
|
||||
$main::LOG_TO_FILE = 0; # write perl output to a file
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# configuration variables that affect the manner of building,
|
||||
# but possibly affecting the outcome.
|
||||
#-------------------------------------------------------------
|
||||
$main::ALIAS_SYM_FILES = $main::DEBUG;
|
||||
$main::CLOBBER_LIBS = 1; # turn on to clobber existing libs and .xSYM files before
|
||||
# building each project
|
||||
# The following two options will delete all dist files (if you have $main::build{dist} turned on),
|
||||
# but leave the directory structure intact.
|
||||
$main::CLOBBER_DIST_ALL = 1; # turn on to clobber all aliases/files inside dist (headers/xsym/libs)
|
||||
$main::CLOBBER_DIST_LIBS = 0; # turn on to clobber only aliases/files for libraries/sym files in dist
|
||||
$main::CLOBBER_IDL_PROJECTS = 0; # turn on to clobber all IDL projects.
|
||||
$main::CLOBBER_PROJECTS = 0; # turn on to remove object code from each project before building it
|
||||
|
||||
$main::UNIVERSAL_INTERFACES_VERSION = 0x0320;
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# configuration variables that are preferences for the build,
|
||||
# style and do not affect what is built.
|
||||
#-------------------------------------------------------------
|
||||
$main::CLOSE_PROJECTS_FIRST = 0;
|
||||
# 1 = close then make (for development),
|
||||
# 0 = make then close (for tinderbox).
|
||||
$main::USE_TIMESTAMPED_LOGS = 0;
|
||||
$main::USE_BUILD_PROGRESS = 1; # track build progress for restartable builds
|
||||
#-------------------------------------------------------------
|
||||
# END OF CONFIG SWITCHES
|
||||
#-------------------------------------------------------------
|
||||
|
||||
$main::BIN_DIRECTORY = $bin_dir;
|
||||
$main::DEFINESOPTIONS_FILE = $config_header_file_name;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// SetupBuildRootDir
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub SetupBuildRootDir($)
|
||||
{
|
||||
my($rel_path_to_script) = @_;
|
||||
|
||||
my($cur_dir) = cwd();
|
||||
$cur_dir =~ s/$rel_path_to_script$//;
|
||||
chdir($cur_dir) || die "Error: failed to set build root directory to '$cur_dir'.\nYou probably need to put 'mozilla' one level down (in a folder).\n";
|
||||
$main::MOZ_SRC = cwd();
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// StartBuildModule
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub StartBuildModule($)
|
||||
{
|
||||
my($module) = @_;
|
||||
|
||||
print("---- Start of $module ----\n");
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// EndBuildModule
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub EndBuildModule($)
|
||||
{
|
||||
my($module) = @_;
|
||||
WriteBuildProgress($module);
|
||||
print("---- End of $module ----\n");
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# GetBinDirectory
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
sub GetBinDirectory()
|
||||
{
|
||||
if ($main::BIN_DIRECTORY eq "") { die "Dist directory not set\n"; }
|
||||
return $main::BIN_DIRECTORY;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# AskAndPersistFile stores the information about the user pick inside
|
||||
# the file $session_storage
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
sub AskAndPersistFile($)
|
||||
{
|
||||
my ($sessionStorage) = @_;
|
||||
my $cvsfile;
|
||||
|
||||
if (( -e $sessionStorage) &&
|
||||
open( SESSIONFILE, $sessionStorage ))
|
||||
{
|
||||
# Read in the path if available
|
||||
$cvsfile = <SESSIONFILE>;
|
||||
chomp $cvsfile;
|
||||
close SESSIONFILE;
|
||||
if ( ! -e $cvsfile )
|
||||
{
|
||||
print STDERR "$cvsfile has disappeared\n";
|
||||
undef $cvsfile;
|
||||
}
|
||||
}
|
||||
unless (defined ($cvsfile))
|
||||
{
|
||||
# make sure that MacPerl is a front process
|
||||
ActivateApplication('McPL');
|
||||
MacPerl::Answer("Could not find your MacCVS session file. Please choose one", "OK");
|
||||
|
||||
# prompt user for the file name, and store it
|
||||
my $macFile = StandardGetFile( 0, "McvD");
|
||||
if ( $macFile->sfGood() )
|
||||
{
|
||||
$cvsfile = $macFile->sfFile();
|
||||
# save the choice if we can
|
||||
if ( open (SESSIONFILE, ">" . $sessionStorage))
|
||||
{
|
||||
printf SESSIONFILE $cvsfile, "\n";
|
||||
close SESSIONFILE;
|
||||
}
|
||||
else
|
||||
{
|
||||
print STDERR "Could not open storage file $sessionStorage for saving $cvsfile\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $cvsfile;
|
||||
}
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# BuildIDLProject
|
||||
#
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub BuildIDLProject($$)
|
||||
{
|
||||
my ($project_path, $module_name) = @_;
|
||||
|
||||
if ($main::CLOBBER_IDL_PROJECTS)
|
||||
{
|
||||
my (@suffix_list) = (".mcp", ".xml");
|
||||
my ($project_name, $project_dir, $suffix) = fileparse($project_path, @suffix_list);
|
||||
if ($suffix eq "") { die "Error: Project, $project_path must end in .xml or .mcp\n"; }
|
||||
|
||||
my($datafolder_path);
|
||||
if ($suffix eq ".xml")
|
||||
{
|
||||
$datafolder_path = $project_dir . "_" . $project_name . " Data:";
|
||||
}
|
||||
else {
|
||||
$datafolder_path = $project_dir . $project_name . " Data:";
|
||||
}
|
||||
|
||||
print STDERR "Deleting IDL data folder: $datafolder_path\n";
|
||||
EmptyTree($datafolder_path);
|
||||
}
|
||||
|
||||
BuildOneProject($project_path, "headers", 0, 0, 0);
|
||||
BuildOneProject($project_path, $module_name.".xpt", 1, 0, 1);
|
||||
}
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# CreateStaticLibTargets
|
||||
#
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
sub CreateXMLStaticLibTargets($)
|
||||
{
|
||||
my($xml_path) = @_;
|
||||
|
||||
my (@suffix_list) = (".xml");
|
||||
my ($project_name, $project_dir, $suffix) = fileparse($xml_path, @suffix_list);
|
||||
if ($suffix eq "") { die "XML munging: $xml_path must end in .xml\n"; }
|
||||
|
||||
#sniff the file to see if we need to fix up broken Pro5-exported XML
|
||||
print "Parsing $xml_path\n";
|
||||
|
||||
my $ide_version = Moz::ProjectXML::SniffProjectXMLIDEVersion($xml_path);
|
||||
if ($ide_version eq "4.0")
|
||||
{
|
||||
my $new_file = $project_dir.$project_name."2.xml";
|
||||
|
||||
print "Cleaning up Pro 5 xml to $new_file\n";
|
||||
|
||||
Moz::ProjectXML::CleanupPro5XML($xml_path, $new_file);
|
||||
|
||||
unlink $xml_path;
|
||||
rename ($new_file, $xml_path);
|
||||
}
|
||||
|
||||
my $doc = Moz::ProjectXML::ParseXMLDocument($xml_path);
|
||||
my @target_list = Moz::ProjectXML::GetTargetsList($doc);
|
||||
my $target;
|
||||
|
||||
my %target_hash; # for easy lookups below
|
||||
foreach $target (@target_list) { $target_hash{$target} = 1; }
|
||||
|
||||
foreach $target (@target_list)
|
||||
{
|
||||
if ($target =~ /(.+).shlb$/) # if this is a shared lib target
|
||||
{
|
||||
my $target_base = $1;
|
||||
my $static_target = $target_base.".o";
|
||||
|
||||
# ensure that this does not exist already
|
||||
if ($target_hash{$static_target}) {
|
||||
print "Static target $static_target already exists in project. Not making\n";
|
||||
next;
|
||||
}
|
||||
|
||||
print "Making static target '$static_target' from target '$target'\n";
|
||||
|
||||
Moz::ProjectXML::CloneTarget($doc, $target, $static_target);
|
||||
Moz::ProjectXML::SetAsStaticLibraryTarget($doc, $static_target, $static_target);
|
||||
}
|
||||
}
|
||||
|
||||
print "Writing XML file to $xml_path\n";
|
||||
my $temp_path = $project_dir."_".$project_name.".xml";
|
||||
Moz::ProjectXML::WriteXMLDocument($doc, $temp_path, $ide_version);
|
||||
Moz::ProjectXML::DisposeXMLDocument($doc);
|
||||
|
||||
if (-e $temp_path)
|
||||
{
|
||||
unlink $xml_path;
|
||||
rename ($temp_path, $xml_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
die "Error: Failed to add new targets to XML project\n";
|
||||
}
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// ProcessProjectXML
|
||||
#//
|
||||
#// Helper routine to allow for XML pre-processing. This should read in the XML, process it,
|
||||
#// and replace the original file with the processed version.
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub ProcessProjectXML($)
|
||||
{
|
||||
my($xml_path) = @_;
|
||||
|
||||
# we need to manually load Moz::ProjectXML, becaues not everyone will have the
|
||||
# required perl modules in their distro.
|
||||
my($cur_dir) = cwd();
|
||||
|
||||
chdir(dirname($0)); # change to the script dir
|
||||
eval "require Moz::ProjectXML";
|
||||
if ($@) { die "Error: could not do Project XML munging because you do not have the correct XML modules installed. Error is:\n################\n $@################"; }
|
||||
|
||||
chdir($cur_dir);
|
||||
|
||||
CreateXMLStaticLibTargets($xml_path);
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// Build one project, and make the alias. Parameters are project path, target name, shared library
|
||||
#// name, make shlb alias (boolean), make xSYM alias (boolean), and is component (boolean).
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub BuildOneProjectWithOutput($$$$$$)
|
||||
{
|
||||
my ($project_path, $target_name, $output_name, $alias_lib, $alias_xSYM, $component) = @_;
|
||||
|
||||
unless ($project_path =~ m/^$main::BUILD_ROOT.+/) { return; }
|
||||
|
||||
my (@suffix_list) = (".mcp", ".xml");
|
||||
my ($project_name, $project_dir, $suffix) = fileparse($project_path, @suffix_list);
|
||||
if ($suffix eq "") { die "Error: Project, $project_path must end in .xml or .mcp\n"; }
|
||||
|
||||
my($dist_dir) = GetBinDirectory();
|
||||
|
||||
# Put libraries in "Essential Files" folder, Components in "Components" folder
|
||||
my($output_dir) = $component ? "Components:" : "Essential Files:";
|
||||
my($output_path) = $dist_dir.$output_dir;
|
||||
|
||||
if ($main::options{static_build})
|
||||
{
|
||||
if ($output_name =~ /\.o$/ || $output_name =~ /\.[Ll]ib$/)
|
||||
{
|
||||
$alias_xSYM = 0;
|
||||
$alias_lib = 1;
|
||||
$output_path = $main::DEBUG ? ":mozilla:dist:static_libs_debug:" : ":mozilla:dist:static_libs:";
|
||||
}
|
||||
}
|
||||
|
||||
# if the flag is on to export projects to XML, export and munge them
|
||||
if ($main::EXPORT_PROJECTS && !($project_path =~ /IDL\.mcp$/))
|
||||
{
|
||||
my $xml_out_path = $project_path;
|
||||
|
||||
$xml_out_path =~ s/\.mcp$/\.xml/;
|
||||
|
||||
# only do this if project is newer?
|
||||
if (! -e $xml_out_path)
|
||||
{
|
||||
ExportProjectToXML(full_path_to($project_path), full_path_to($xml_out_path));
|
||||
ProcessProjectXML($xml_out_path);
|
||||
}
|
||||
}
|
||||
|
||||
# if the flag is set to use XML projects, default to XML if the file
|
||||
# is present.
|
||||
if ($main::USE_XML_PROJECTS && !($project_path =~ /IDL\.mcp$/))
|
||||
{
|
||||
my $xml_project_path = $project_dir.$project_name.".xml";
|
||||
if (-e $xml_project_path)
|
||||
{
|
||||
$project_path = $xml_project_path;
|
||||
$suffix = ".xml";
|
||||
}
|
||||
}
|
||||
|
||||
if ($suffix eq ".xml")
|
||||
{
|
||||
my($xml_path) = $project_path;
|
||||
# Prepend an "_" onto the name of the generated project file so it doesn't conflict
|
||||
$project_path = $project_dir . "_" . $project_name . ".mcp";
|
||||
my($project_modtime) = (-e $project_path ? GetFileModDate($project_path) : 0);
|
||||
my($xml_modtime) = (-e $xml_path ? GetFileModDate($xml_path) : 0);
|
||||
|
||||
if ($xml_modtime > $project_modtime)
|
||||
{
|
||||
print("Importing $project_path from $project_name.xml.\n");
|
||||
unlink($project_path);
|
||||
# Might want to delete the "xxx.mcp Data" dir ???
|
||||
ImportXMLProject(full_path_to($xml_path), full_path_to($project_path));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($main::CLOBBER_LIBS)
|
||||
{
|
||||
unlink "$project_dir$output_name"; # it's OK if these fail
|
||||
unlink "$project_dir$output_name.xSYM";
|
||||
}
|
||||
|
||||
DoBuildProject($project_path, $target_name, $main::CLOBBER_PROJECTS);
|
||||
|
||||
$alias_lib ? MakeAlias("$project_dir$output_name", "$output_path") : 0;
|
||||
$alias_xSYM ? MakeAlias("$project_dir$output_name.xSYM", "$output_path") : 0;
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// For compatiblity with existing scripts, BuildOneProject now just calls
|
||||
#// BuildOneProjectWithOutput, with the output name and target name identical.
|
||||
#// Note that this routine assumes that the target name and the shared libary name
|
||||
#// are the same.
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub BuildOneProject($$$$$)
|
||||
{
|
||||
my ($project_path, $target_name, $alias_lib, $alias_xSYM, $component) = @_;
|
||||
|
||||
BuildOneProjectWithOutput($project_path, $target_name, $target_name,
|
||||
$alias_lib, $alias_xSYM, $component);
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// For compatiblity with existing scripts, BuildProject now just calls
|
||||
#// BuildOneProjectWithOutput, with the output name and target name identical.
|
||||
#// Note that this routine assumes that the target name and the shared libary name
|
||||
#// are the same. No aliases of the output are made.
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub BuildProject($$)
|
||||
{
|
||||
my ($project_path, $target_name) = @_;
|
||||
|
||||
BuildOneProjectWithOutput($project_path, $target_name, $target_name, 0, 0, 0);
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// Identical to BuildProject but clobbers the project before building it.
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub BuildProjectClean($$)
|
||||
{
|
||||
my ($project_path, $target_name) = @_;
|
||||
my ($save_clobber_flag) = $main::CLOBBER_PROJECTS;
|
||||
$main::CLOBBER_PROJECTS = 1;
|
||||
BuildOneProjectWithOutput($project_path, $target_name, $target_name, 0, 0, 0);
|
||||
$main::CLOBBER_PROJECTS = $save_clobber_flag;
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// Make resource aliases for one directory
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub BuildFolderResourceAliases($$)
|
||||
{
|
||||
my($src_dir, $dest_dir) = @_;
|
||||
|
||||
# get a list of all the resource files
|
||||
opendir(SRCDIR, $src_dir) || die("can't open $src_dir");
|
||||
my(@resource_files) = readdir(SRCDIR);
|
||||
closedir(SRCDIR);
|
||||
|
||||
# make aliases for each one into the dest directory
|
||||
print("Placing aliases to all files from $src_dir in $dest_dir\n");
|
||||
for ( @resource_files )
|
||||
{
|
||||
next if $_ eq "CVS";
|
||||
#print(" Doing $_\n");
|
||||
if (-l $src_dir.$_)
|
||||
{
|
||||
print(" $_ is an alias\n");
|
||||
next;
|
||||
}
|
||||
my($file_name) = $src_dir . $_;
|
||||
MakeAlias($file_name, $dest_dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// DelayFor
|
||||
#//
|
||||
#// Delay for the given number of seconds, allowing the script to be cancelled
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub DelayFor($)
|
||||
{
|
||||
my($delay_secs) = @_;
|
||||
|
||||
STDOUT->autoflush(1);
|
||||
|
||||
my($end_time) = time() + $delay_secs;
|
||||
|
||||
my($last_time) = 0;
|
||||
my($cur_time) = time();
|
||||
|
||||
while ($cur_time < $end_time)
|
||||
{
|
||||
$cur_time = time();
|
||||
if ($cur_time > $last_time)
|
||||
{
|
||||
print ".";
|
||||
$last_time = $cur_time;
|
||||
}
|
||||
|
||||
WaitNextEvent();
|
||||
}
|
||||
|
||||
print "\n";
|
||||
STDOUT->autoflush(0);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// TimeStart
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub TimeStart()
|
||||
{
|
||||
return time();
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// TimeEnd
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub TimeEnd($$)
|
||||
{
|
||||
use integer;
|
||||
|
||||
my($start_time, $operation_name) = @_;
|
||||
my($end_time) = time();
|
||||
|
||||
my($tot_sec) = $end_time - $start_time;
|
||||
|
||||
my($seconds) = $tot_sec;
|
||||
|
||||
my($hours) = $seconds / (60 * 60);
|
||||
$seconds -= $hours * (60 * 60);
|
||||
|
||||
my($minutes) = $seconds / 60;
|
||||
$seconds -= $minutes * 60;
|
||||
|
||||
print "$operation_name took $hours hours $minutes minutes and $seconds seconds\n";
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// Remove all files from a tree, leaving directories intact (except "CVS").
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub EmptyTree($)
|
||||
{
|
||||
my ($root) = @_;
|
||||
#print "EmptyTree($root)\n";
|
||||
opendir(DIR, $root);
|
||||
my $sub;
|
||||
foreach $sub (readdir(DIR))
|
||||
{
|
||||
my $fullpathname = $root.$sub; # -f, -d only work on full paths
|
||||
|
||||
# Don't call empty tree for the alias of a directory.
|
||||
# -d returns true for the alias of a directory, false for a broken alias)
|
||||
|
||||
if (-d $fullpathname)
|
||||
{
|
||||
if (-l $fullpathname) # delete aliases
|
||||
{
|
||||
unlink $fullpathname;
|
||||
next;
|
||||
}
|
||||
EmptyTree($fullpathname.":");
|
||||
if ($sub eq "CVS")
|
||||
{
|
||||
#print "rmdir $fullpathname\n";
|
||||
rmdir $fullpathname;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unless (unlink $fullpathname) { die "Failed to delete $fullpathname\n"; }
|
||||
}
|
||||
}
|
||||
closedir(DIR);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// Recurse through a directory hierarchy, looking for MANIFEST files.
|
||||
#// Currently unused.
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub ScanForManifestFiles($$$$)
|
||||
{
|
||||
my($dir, $theme_root, $theme_name, $dist_dir) = @_;
|
||||
|
||||
opendir(DIR, $dir) or die "Cannot open dir $dir\n";
|
||||
my @files = readdir(DIR);
|
||||
closedir DIR;
|
||||
|
||||
my $file;
|
||||
|
||||
foreach $file (@files)
|
||||
{
|
||||
my $filepath = $dir.":".$file;
|
||||
|
||||
if (-d $filepath)
|
||||
{
|
||||
# print "Looking for MANIFEST files in $filepath\n";
|
||||
ScanForManifestFiles($filepath, $theme_root, $theme_name, $dist_dir);
|
||||
}
|
||||
elsif ($file eq "MANIFEST")
|
||||
{
|
||||
# print "Doing manifest file $filepath\n";
|
||||
|
||||
# Get the dest path from the first line of the file
|
||||
|
||||
open(MANIFEST, $filepath) || die "Could not open file $file";
|
||||
# Read in the path if available
|
||||
my($dest_line) = <MANIFEST>;
|
||||
chomp $dest_line;
|
||||
close MANIFEST;
|
||||
|
||||
$dest_line =~ s|^#!dest[\t ]+|| || die "No destination line found in $filepath\n";
|
||||
|
||||
my($dest_path) = $dist_dir."chrome:skins:$theme_name:$dest_line";
|
||||
# print " Destination is $dest_path\n";
|
||||
|
||||
InstallResources($filepath, "$dest_path", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-----------------------------------------------
|
||||
# SetupBuildLog
|
||||
#-----------------------------------------------
|
||||
sub SetupBuildLog($$)
|
||||
{
|
||||
my($logfile_path, $timestamped_log) = @_;
|
||||
|
||||
my($logdir) = "";
|
||||
my($logfile) = $logfile_path;
|
||||
|
||||
if ($logfile_path =~ /(.+?:)([^:]+)$/) # ? for non-greedy match
|
||||
{
|
||||
$logdir = $1;
|
||||
$logfile = $2;
|
||||
|
||||
mkpath($logdir);
|
||||
}
|
||||
|
||||
if ($timestamped_log)
|
||||
{
|
||||
#Use time-stamped names so that you don't clobber your previous log file!
|
||||
my $now = localtime();
|
||||
while ($now =~ s@:@.@) {} # replace all colons by periods
|
||||
OpenErrorLog("${logdir}${now}");
|
||||
}
|
||||
else
|
||||
{
|
||||
OpenErrorLog("${logdir}${logfile}");
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------
|
||||
# SetBuildNumber
|
||||
#-----------------------------------------------
|
||||
sub SetBuildNumber($$)
|
||||
{
|
||||
my($build_num_file, $files_to_touch) = @_;
|
||||
|
||||
# Make sure we add the config dir to search, to pick up mozBDate.pm
|
||||
# Need to do this dynamically, because this module can be used before
|
||||
# mozilla/config has been checked out.
|
||||
|
||||
my ($inc_path) = $0; # $0 is the path to the parent script
|
||||
$inc_path =~ s/:build:mac:build_scripts:.+$/:config/;
|
||||
push(@INC, $inc_path);
|
||||
|
||||
require mozBDate;
|
||||
|
||||
mozBDate::UpdateBuildNumber($build_num_file, $main::MOZILLA_OFFICIAL);
|
||||
|
||||
my($file);
|
||||
foreach $file (@$files_to_touch)
|
||||
{
|
||||
print "Writing build number to $file from ${file}.in\n";
|
||||
mozBDate::SubstituteBuildNumber($file, $build_num_file, "${file}.in");
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------
|
||||
# SetTimeBomb
|
||||
#-----------------------------------------------
|
||||
sub SetTimeBomb($$)
|
||||
{
|
||||
my ($warn_days, $bomb_days) = @_;
|
||||
|
||||
system("perl :mozilla:config:mac-set-timebomb.pl $warn_days $bomb_days");
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// Regenerate a configuration header file if necessary
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub UpdateConfigHeader($)
|
||||
{
|
||||
my($config_path) = @_;
|
||||
|
||||
my($config, $oldconfig) = ("", "");
|
||||
my($define, $definevalue, $defines);
|
||||
my($k, $l,);
|
||||
|
||||
foreach $k (keys(%main::options))
|
||||
{
|
||||
if ($main::options{$k})
|
||||
{
|
||||
foreach $l (keys(%{$main::optiondefines{$k}}))
|
||||
{
|
||||
$my::defines{$l} = $main::optiondefines{$k}{$l};
|
||||
print "Setting up my::defines{$l}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $config_headerfile = current_directory().$config_path;
|
||||
if (-e $config_headerfile)
|
||||
{
|
||||
open(CONFIG_HEADER, "< $config_headerfile") || die "$config_headerfile: $!\n";
|
||||
my($line);
|
||||
while ($line = <CONFIG_HEADER>)
|
||||
{
|
||||
if ($line =~ m/#define\s+([^\s]*)\s+([^\s]*)\s*\n/)
|
||||
{
|
||||
$define = $1;
|
||||
$definevalue = $2;
|
||||
|
||||
#canonicalize so that whitespace changes are not significant
|
||||
my $canon_value = "#define " . $define . " " . $definevalue . "\n";
|
||||
$oldconfig .= $canon_value;
|
||||
|
||||
if (exists ($my::defines{$define}) and ($my::defines{$define} == $definevalue))
|
||||
{
|
||||
delete $my::defines{$define};
|
||||
$config .= $canon_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
close(CONFIG_HEADER);
|
||||
}
|
||||
|
||||
if (%my::defines)
|
||||
{
|
||||
foreach $k (keys(%my::defines))
|
||||
{
|
||||
$config .= "#define " . $k . " " . $my::defines{$k} . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
my $file_name = basename($config_headerfile);
|
||||
if (($config ne $oldconfig) || (!-e $config_headerfile))
|
||||
{
|
||||
printf("Writing new configuration header $file_name\n");
|
||||
open(CONFIG_HEADER, "> $config_headerfile") || die "$config_headerfile: $!\n";
|
||||
print(CONFIG_HEADER "/* This file is auto-generated based on build options. Do not edit. */\n");
|
||||
print CONFIG_HEADER ($config);
|
||||
close(CONFIG_HEADER);
|
||||
|
||||
MacPerl::SetFileInfo("CWIE", "TEXT", $config_headerfile);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Configuration header $file_name is up-to-date\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
@@ -1,660 +0,0 @@
|
||||
#!perl
|
||||
package Moz::CodeWarriorLib;
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
CodeWarriorLib - supply interface to CodeWarrior
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
#!perl
|
||||
use CodeWarriorLib;
|
||||
CodeWarriorLib::activate();
|
||||
$had_errors = CodeWarriorLib::build_project(
|
||||
$project_path, $target_name, $recent_errors_file, $clean_build
|
||||
);
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Replaces the AppleScript library I<CodeWarriorLib>.
|
||||
|
||||
=over 4
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
|
||||
use Cwd;
|
||||
use File::Basename;
|
||||
|
||||
use Mac::Types;
|
||||
use Mac::Events;
|
||||
use Mac::AppleEvents;
|
||||
use Mac::AppleEvents::Simple;
|
||||
use Mac::Processes;
|
||||
use Mac::MoreFiles;
|
||||
use Mac::StandardFile;
|
||||
|
||||
|
||||
use vars qw($VERSION);
|
||||
$VERSION = '1.02';
|
||||
|
||||
my($app) = 'CWIE';
|
||||
my($scriptDir) = cwd(); # could use $0 for this
|
||||
my($ide_loc_file) = "";
|
||||
|
||||
# 0 == don't switch CWIE to front app in do_event(), 1 == do switch
|
||||
# note: activate() still switches when called
|
||||
$Mac::AppleEvents::Simple::SWITCH = 0;
|
||||
# $Mac::AppleEvents::Simple::WARN = 1;
|
||||
|
||||
# supply your own path to the source here
|
||||
#_test('PowerPudgeIV:mozilla:mozilla:');
|
||||
|
||||
# If you want to understand the gobbldeygook that's used to build Apple Events,
|
||||
# you should start by reading the AEGizmos documentation.
|
||||
|
||||
=pod
|
||||
|
||||
=item _get_project($full_path)
|
||||
|
||||
A private routine returning a reference to the open project with the given name,
|
||||
or else the empty string (when that project is not open)
|
||||
|
||||
full_path is a string identifying the project to be built and is of the form,
|
||||
e.g., "HD:ProjectFolder:MyProject.mcp". It must be supplied.
|
||||
|
||||
=cut
|
||||
|
||||
sub _get_project ($) {
|
||||
my(
|
||||
$full_path, $candidate_projects
|
||||
) = @_;
|
||||
$candidate_projects = _doc_named(basename($full_path, '*'));
|
||||
if ($candidate_projects) {
|
||||
my($cps) = _get_dobj($candidate_projects);
|
||||
my($num) = AECountItems($cps);
|
||||
if ($num) { # is a list
|
||||
foreach (1 .. AECountItems($cps)) {
|
||||
my($cp) = AEGetNthDesc($cps, $_);
|
||||
if (lc $full_path eq lc _full_path($cp)) {
|
||||
return($cp);
|
||||
}
|
||||
}
|
||||
} else { # is only one, not a list
|
||||
if (lc $full_path eq lc _full_path($cps)) {
|
||||
return($cps);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
=pod
|
||||
|
||||
=item build_project
|
||||
|
||||
Build a selected target of a project, saving any errors to a file, if supplied.
|
||||
|
||||
full_path is a string identifying the project to be built and is of the form,
|
||||
e.g., "HD:ProjectFolder:MyProject.mcp". It must be supplied.
|
||||
|
||||
If target_name is the empty string, the current target of the selected project
|
||||
will be built, else, target_name should be a string matching a target name in
|
||||
the selected project.
|
||||
|
||||
If error_path is the empty string, errors will not be saved to a file,
|
||||
else, error_path should be the full path of a file to save error messages into.
|
||||
|
||||
=cut
|
||||
|
||||
$CodeWarriorLib::CLOSE_PROJECTS_FIRST = 0; # If true we close then make. If false, make then close.
|
||||
my $last_project_built = "";
|
||||
my $last_project_was_closed = 0;
|
||||
|
||||
sub build_project ($;$$$) {
|
||||
my(
|
||||
$full_path, $target_name, $error_path,
|
||||
$remove_object, $p, $project_was_closed, $had_errors
|
||||
) = @_;
|
||||
_close_errors_window();
|
||||
|
||||
if ($CodeWarriorLib::CLOSE_PROJECTS_FIRST && ($last_project_built ne $full_path))
|
||||
{
|
||||
# If we're in "close first" mode, we don't close if the current project
|
||||
# is the same as the previous one.
|
||||
if ($last_project_was_closed) {
|
||||
$p = _get_project($last_project_built);
|
||||
_close($p);
|
||||
}
|
||||
$last_project_built = $full_path;
|
||||
$last_project_was_closed = 0; # now refers to the new project
|
||||
}
|
||||
$project_was_closed = 0;
|
||||
while (1) {
|
||||
$p = _get_project($full_path);
|
||||
if (!$p) {
|
||||
if ($project_was_closed) {
|
||||
print "### Error - request for project document failed after opening\n";
|
||||
die "### possibly CW Pro 4 bug: be sure to close your Find window\n";
|
||||
}
|
||||
$project_was_closed = 1;
|
||||
$last_project_was_closed = 1;
|
||||
_open_file($full_path);
|
||||
} else {
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
$had_errors = 0;
|
||||
if ($target_name eq '') {
|
||||
if ($remove_object) {_remove_object($p)}
|
||||
_build($p);
|
||||
} else {
|
||||
if ($remove_object) {_remove_object($p, $target_name)}
|
||||
_build($p, $target_name);
|
||||
}
|
||||
|
||||
if ($error_path ne '') {
|
||||
_save_errors_window($error_path);
|
||||
}
|
||||
$had_errors = _close_errors_window();
|
||||
|
||||
if (!$CodeWarriorLib::CLOSE_PROJECTS_FIRST)
|
||||
{
|
||||
if ($project_was_closed) {
|
||||
$p = _get_project($full_path);
|
||||
_close($p);
|
||||
}
|
||||
}
|
||||
|
||||
return($had_errors);
|
||||
}
|
||||
|
||||
=pod
|
||||
|
||||
=item appIsRunning()
|
||||
|
||||
=cut
|
||||
sub _appIsRunning($)
|
||||
{
|
||||
my ($appSignature) = @_;
|
||||
my ($psi);
|
||||
my ($found) = 0;
|
||||
my ($appPSN);
|
||||
|
||||
foreach $psi (values(%Process))
|
||||
{
|
||||
if ($psi->processSignature() eq $appSignature)
|
||||
{
|
||||
$appPSN = $psi->processNumber();
|
||||
$found = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
return $found;
|
||||
}
|
||||
|
||||
=pod
|
||||
|
||||
=item appIsFrontmost()
|
||||
|
||||
=cut
|
||||
sub _appIsFrontmost($)
|
||||
{
|
||||
my ($appSignature) = @_;
|
||||
my ($psi);
|
||||
my ($found) = 0;
|
||||
my ($appPSN);
|
||||
|
||||
foreach $psi (values(%Process))
|
||||
{
|
||||
if ($psi->processSignature() eq $appSignature)
|
||||
{
|
||||
$appPSN = $psi->processNumber();
|
||||
$found = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
return (GetFrontProcess() == $appPSN);
|
||||
}
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
=item activate()
|
||||
|
||||
Launches CodeWarrior and brings it to the front.
|
||||
|
||||
Once found, path will be saved in $idepath_file for future reference.
|
||||
Edit or delete this file to change the location of the IDE. If app is
|
||||
moved, C<activate()> will prompt for a new location.
|
||||
|
||||
First looks for an open CodeWarrior app. Second, tries to open previously
|
||||
saved location in ':idepath.txt'. Third, tries to find it and allow user
|
||||
to choose it with Navigation Services (if present). Fourth, uses good old
|
||||
GUSI routines built-in to MacPerl for a Choose Directory dialog box.
|
||||
|
||||
=cut
|
||||
|
||||
sub activate ($) {
|
||||
|
||||
$ide_loc_file = $_[0]; # save in global
|
||||
|
||||
my($filepath, $appath, $psi) = ($ide_loc_file);
|
||||
|
||||
foreach $psi (values(%Process)) {
|
||||
if ($psi->processSignature() eq $app) {
|
||||
$appath = $psi->processAppSpec();
|
||||
_save_appath($filepath, $appath);
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$appath || !-x $appath) {
|
||||
$appath = _read_appath($filepath);
|
||||
}
|
||||
|
||||
if (!$appath || ! -x $appath)
|
||||
{
|
||||
# make sure that MacPerl is a front process
|
||||
#ActivateApplication('McPL');
|
||||
MacPerl::Answer("Please locate the CodeWarrior application.", "OK");
|
||||
|
||||
# prompt user for the file name, and store it
|
||||
my $macFile = StandardGetFile( 0, "APPL");
|
||||
if ( $macFile->sfGood() )
|
||||
{
|
||||
$appath = $macFile->sfFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
die "Operation canceled\n";
|
||||
}
|
||||
|
||||
# if (eval {require Mac::Navigation}) {
|
||||
# my($options, $nav);
|
||||
# Mac::Navigation->import();
|
||||
# $options = NavGetDefaultDialogOptions();
|
||||
# $options->message('Where is CodeWarrior IDE?');
|
||||
# $options->windowTitle('Find CodeWarrior IDE');
|
||||
# $nav = NavChooseObject($Application{$app}, $options);
|
||||
# die "CodeWarrior IDE not found.\n" if (!$nav || !$nav->file(1));
|
||||
# $appath = $nav->file(1);
|
||||
# } else {
|
||||
# local(*D);
|
||||
# my $cwd = `pwd`;
|
||||
# $appath = _get_folder(
|
||||
# 'Where is the CW IDE folder?',
|
||||
# dirname($Application{$app})
|
||||
# );
|
||||
# die "CodeWarrior IDE not found.\n" if !$appath;
|
||||
# opendir(D, $appath) or die $!;
|
||||
# chdir($appath);
|
||||
# foreach my $file (sort readdir (D)) {
|
||||
# my(@app) = MacPerl::GetFileInfo($file);
|
||||
# if ($app[0] && $app[1] &&
|
||||
# $app[1] eq 'APPL' && $app[0] eq $app
|
||||
# ) {
|
||||
# $appath .= $file;
|
||||
# last;
|
||||
# }
|
||||
# }
|
||||
# chomp($cwd);
|
||||
# chdir($cwd);
|
||||
# }
|
||||
_save_appath($filepath, $appath);
|
||||
}
|
||||
|
||||
my($lp) = LaunchParam->new(
|
||||
launchAppSpec => $appath,
|
||||
launchControlFlags => launchContinue() + launchNoFileFlags()
|
||||
);
|
||||
|
||||
unless (LaunchApplication($lp)) {
|
||||
unlink($filepath);
|
||||
die $^E;
|
||||
}
|
||||
|
||||
# wait for CodeWarrior to show up in the list of processes
|
||||
while (!_appIsRunning('CWIE'))
|
||||
{
|
||||
WaitNextEvent();
|
||||
}
|
||||
|
||||
# wait for CodeWarrior to come to the front
|
||||
while (!_appIsFrontmost('CWIE'))
|
||||
{
|
||||
WaitNextEvent();
|
||||
}
|
||||
}
|
||||
|
||||
=pod
|
||||
|
||||
=item getCodeWarriorPath()
|
||||
|
||||
Returns a file path relative to the CodeWarrior folder
|
||||
|
||||
=cut
|
||||
|
||||
sub getCodeWarriorPath($)
|
||||
{
|
||||
my($subfolder)=@_;
|
||||
|
||||
my($app_path) = _read_appath($ide_loc_file);
|
||||
if ($app_path eq "") { die "Error: Failed to get CodeWarrior IDE path\n"; }
|
||||
|
||||
my($codewarrior_root) = $app_path;
|
||||
$codewarrior_root =~ s/[^:]*$//;
|
||||
return ($codewarrior_root . $subfolder);
|
||||
}
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
=item getCodeWarriorIDEName()
|
||||
|
||||
Returns the name of the CodeWarrior application
|
||||
|
||||
=cut
|
||||
|
||||
sub getCodeWarriorIDEName()
|
||||
{
|
||||
my($subfolder)=@_;
|
||||
|
||||
my($app_path) = _read_appath($ide_loc_file);
|
||||
if ($app_path eq "") { die "Error: Failed to get CodeWarrior IDE path\n"; }
|
||||
|
||||
my(@codewarrior_path) = split(/:/, $app_path);
|
||||
return pop(@codewarrior_path);
|
||||
}
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
=item quit()
|
||||
|
||||
Quits CodeWarrior.
|
||||
|
||||
=cut
|
||||
|
||||
sub quit() {
|
||||
|
||||
$last_project_built = "";
|
||||
$last_project_was_closed = 0;
|
||||
|
||||
my($evt) = do_event(qw/aevt quit/, $app);
|
||||
}
|
||||
|
||||
|
||||
sub _build ($;$) {
|
||||
my($evt);
|
||||
if ($_[1]) {
|
||||
my($prm) =
|
||||
q"'----':obj {form:name, want:type(TRGT), seld:TEXT(@), from:" .
|
||||
AEPrint($_[0]) . '}';
|
||||
$evt = do_event(qw/CWIE MAKE/, $app, $prm, $_[1]);
|
||||
} else {
|
||||
my($prm) = q"'----':" . AEPrint($_[0]);
|
||||
$evt = do_event(qw/CWIE MAKE/, $app, $prm);
|
||||
}
|
||||
}
|
||||
|
||||
sub _remove_object ($;$) {
|
||||
my($evt);
|
||||
if ($_[1]) {
|
||||
my($prm) =
|
||||
q"'----':obj {form:name, want:type(TRGT), seld:TEXT(@), from:" .
|
||||
AEPrint($_[0]) . '}';
|
||||
$evt = do_event(qw/CWIE RMOB/, $app, $prm, $_[1]);
|
||||
} else {
|
||||
my($prm) = q"'----':" . AEPrint($_[0]);
|
||||
$evt = do_event(qw/CWIE RMOB/, $app, $prm);
|
||||
}
|
||||
}
|
||||
|
||||
sub _open_file ($) {
|
||||
my($prm) =
|
||||
q"'----':obj {form:name, want:type(alis), " .
|
||||
q"seld:TEXT(@), from:'null'()}";
|
||||
|
||||
do_event(qw/aevt odoc/, $app, $prm, $_[0]);
|
||||
}
|
||||
|
||||
sub import_project ($$) {
|
||||
my($xml_file, $project_path) = @_;
|
||||
|
||||
my($prm) = "kocl:type(PRJD), rtyp:TEXT(@), data:TEXT(@), &subj:'null'()";
|
||||
|
||||
my($evt) = do_event(qw/core crel/, $app, $prm, $project_path, $xml_file);
|
||||
my($result) = _get_event_result($evt);
|
||||
|
||||
if ($result eq "") {
|
||||
_close(_get_project($project_path));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub export_project ($$) {
|
||||
my($project_path, $xml_out_path) = @_;
|
||||
my($p, $project_was_closed);
|
||||
|
||||
$project_was_closed = 0;
|
||||
while (1) {
|
||||
$p = _get_project($project_path);
|
||||
if (!$p) {
|
||||
if ($project_was_closed) {
|
||||
print "### Error - request for project document failed after opening\n";
|
||||
die "### possibly CW bug: be sure to close your Find window\n";
|
||||
}
|
||||
$project_was_closed = 1;
|
||||
_open_file($project_path);
|
||||
} else {
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
# avoid problems with the Project Messages window
|
||||
_close_named_window("Project Messages");
|
||||
|
||||
my($prm) =
|
||||
q"'----':obj {form:indx, want:type(PRJD), " .
|
||||
q"seld:1, from:'null'()}, kfil:TEXT(@)";
|
||||
|
||||
my($evt) = do_event(qw/CWIE EXPT/, $app, $prm, $xml_out_path);
|
||||
|
||||
if ($project_was_closed) {
|
||||
$p = _get_project($project_path);
|
||||
_close($p);
|
||||
}
|
||||
|
||||
return _get_event_result($evt);
|
||||
}
|
||||
|
||||
sub _doc_named ($) {
|
||||
my($prm) =
|
||||
q"'----':obj {form:test, want:type(docu), from:'null'(), " .
|
||||
q"seld:cmpd{relo:'= ', 'obj1':obj {form:prop, want:type" .
|
||||
q"(prop), seld:type(pnam), from:'exmn'()}, 'obj2':TEXT(@)}}";
|
||||
|
||||
my($evt) = do_event(qw/core getd/, $app, $prm, $_[0]);
|
||||
return($evt->{REPLY} eq 'aevt\ansr{}' ? undef : $evt);
|
||||
}
|
||||
|
||||
sub _full_path ($) {
|
||||
my($obj) = $_[0];
|
||||
my($prm) =
|
||||
q"'----':obj {form:prop, want:type(prop), seld:type(FILE), " .
|
||||
q"from:" . AEPrint($_[0]) . q"}, rtyp:type(TEXT)";
|
||||
my($evt) = do_event(qw/core getd/, $app, $prm);
|
||||
|
||||
return MacPerl::MakePath(
|
||||
MacUnpack('fss ', (
|
||||
AEGetParamDesc($evt->{REP}, keyDirectObject()))->data()->get()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
sub _save_errors_window ($) {
|
||||
my($prm) =
|
||||
q"'----':obj {form:name, want:type(alis), seld:TEXT(@), from:'null'()}";
|
||||
do_event(qw/MMPR SvMs/, $app, $prm, $_[0]);
|
||||
}
|
||||
|
||||
|
||||
sub _close_errors_window () {
|
||||
return _close_named_window('Errors & Warnings');
|
||||
}
|
||||
|
||||
|
||||
sub _close_named_window ($) {
|
||||
my($window_name) = @_;
|
||||
|
||||
my($prm) =
|
||||
q"'----':obj {form:name, want:type(cwin), " .
|
||||
q"seld:TEXT(@), from:'null'()}";
|
||||
|
||||
my($evt) = do_event(qw/core clos/, $app, $prm, $window_name);
|
||||
return($evt->{REPLY} eq 'aevt\ansr{}' ? 1 : 0);
|
||||
}
|
||||
|
||||
sub _close () {
|
||||
my($prm) = q"'----':" . AEPrint($_[0]);
|
||||
do_event(qw/core clos/, $app, $prm);
|
||||
}
|
||||
|
||||
sub _get_dobj ($) {
|
||||
return(AEGetParamDesc($_[0]->{REP}, keyDirectObject()));
|
||||
}
|
||||
|
||||
sub _get_folder ($$) {
|
||||
require 'GUSI.ph';
|
||||
my($prompt, $default) = @_;
|
||||
MacPerl::Choose(
|
||||
GUSI::AF_FILE(), 0, $prompt, '',
|
||||
GUSI::CHOOSE_DIR() + ($default ? &GUSI::CHOOSE_DEFAULT : 0),
|
||||
$default
|
||||
);
|
||||
}
|
||||
|
||||
sub _get_event_result ($)
|
||||
{
|
||||
my($evt) = @_;
|
||||
|
||||
my($result) = $evt->{ERROR};
|
||||
|
||||
if ( $result eq "" && $evt->{ERRNO} != 0 )
|
||||
{
|
||||
$result = "unknown error (".$evt->{ERRNO}.")";
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
sub _save_appath ($$) {
|
||||
|
||||
my($cwd) = cwd(); # remember the current working dir
|
||||
chdir($scriptDir); # change dir to the script dir
|
||||
|
||||
local(*F);
|
||||
open(F, '>' . $_[0]) or die $!;
|
||||
print F $_[1];
|
||||
close(F);
|
||||
|
||||
chdir($cwd); # restore the cwd
|
||||
}
|
||||
|
||||
sub _read_appath ($) {
|
||||
|
||||
my($filepath) = @_;
|
||||
|
||||
my($cwd) = cwd(); # remember the current working dir
|
||||
chdir($scriptDir); # change dir to the script dir
|
||||
|
||||
if (! -e $filepath) {
|
||||
return "";
|
||||
}
|
||||
|
||||
local(*F);
|
||||
open(F, $filepath);
|
||||
my($appath) = <F>;
|
||||
close(F);
|
||||
|
||||
chdir($cwd); # restore the cwd
|
||||
return($appath);
|
||||
}
|
||||
|
||||
|
||||
sub _test ($) {
|
||||
activate($ide_loc_file);
|
||||
my($path) = $_[0];
|
||||
build_project(
|
||||
"${path}modules:xml:macbuild:XML.mcp", '',
|
||||
"${path}build:mac:Mozilla.BuildLog.part"
|
||||
);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=pod
|
||||
|
||||
=back
|
||||
|
||||
=head1 HISTORY
|
||||
|
||||
=over 4
|
||||
|
||||
=item v1.02, September 23, 1998
|
||||
|
||||
Made fixes in finding and saving location of CodeWarrior IDE.
|
||||
|
||||
=item v1.01, June 1, 1998
|
||||
|
||||
Made fixes to C<chdir()> in C<activate()>, made C<activate()> more robust
|
||||
in finding CodeWarrior IDE, added global variable to NOT switch to IDE
|
||||
for each sent event, a few other fixes.
|
||||
|
||||
=item v1.00, May 30, 1998
|
||||
|
||||
First shot
|
||||
|
||||
=back
|
||||
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
Chris Nandor F<E<lt>pudge@pobox.comE<gt>>, and the author of the
|
||||
original I<CodeWarriorLib>, Scott Collins F<E<lt>scc@netscape.comE<gt>>.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
BuildProject L<Moz>.
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
The contents of this file are subject to the Netscape 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/NPL/
|
||||
|
||||
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 Mozilla Communicator client code, released
|
||||
March 31, 1998.
|
||||
|
||||
The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
=cut
|
||||
@@ -1,576 +0,0 @@
|
||||
#!perl -w
|
||||
package Moz::Jar;
|
||||
|
||||
#
|
||||
# Module for creating jar files, either using a jar manifest, or
|
||||
# simply jarring up folders on disk.
|
||||
#
|
||||
|
||||
require 5.004;
|
||||
require Exporter;
|
||||
|
||||
use strict;
|
||||
use Archive::Zip;
|
||||
use File::Path;
|
||||
|
||||
use Mac::Files;
|
||||
|
||||
use Moz::Moz;
|
||||
|
||||
use vars qw( @ISA @EXPORT );
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(
|
||||
CreateJarFileFromDirectory
|
||||
CreateJarFromManifest
|
||||
WriteOutJarFiles
|
||||
SanityCheckJarOptions
|
||||
);
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Add the contents of a directory to the zip file
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
sub _addDirToJar($$$$)
|
||||
{
|
||||
my($dir, $jar_root, $zip, $compress) = @_;
|
||||
|
||||
opendir(DIR, $dir) or die "Error: Cannot open dir $dir\n";
|
||||
my @files = readdir(DIR);
|
||||
closedir DIR;
|
||||
|
||||
my $unix_jar_root = $jar_root;
|
||||
$unix_jar_root =~ s|:|/|g; # colon to slash conversion
|
||||
|
||||
my $file;
|
||||
|
||||
foreach $file (@files)
|
||||
{
|
||||
my $filepath = $dir.":".$file;
|
||||
|
||||
if (-d $filepath)
|
||||
{
|
||||
print "Adding files to jar from $filepath\n";
|
||||
_addDirToJar($filepath, $jar_root, $zip, $compress);
|
||||
}
|
||||
else
|
||||
{
|
||||
my $member = Archive::Zip::Member->newFromFile($filepath);
|
||||
die "Error: Failed to create zip file member $filepath\n" unless $member;
|
||||
|
||||
my $unixName = $filepath;
|
||||
$unixName =~ s|:|/|g; # colon to slash conversion
|
||||
$unixName =~ s|^$unix_jar_root||; # relativise
|
||||
|
||||
$member->fileName($unixName);
|
||||
|
||||
# print "Adding $file as $unixName\n";
|
||||
|
||||
if ($compress) {
|
||||
$member->desiredCompressionMethod(Archive::Zip::COMPRESSION_DEFLATED);
|
||||
} else {
|
||||
$member->desiredCompressionMethod(Archive::Zip::COMPRESSION_STORED);
|
||||
}
|
||||
|
||||
$zip->addMember($member);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Add the contents of a directory to the zip file
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
sub CreateJarFileFromDirectory($$$)
|
||||
{
|
||||
my($srcdir, $jarpath, $compress) = @_;
|
||||
|
||||
my $zip = Archive::Zip->new();
|
||||
|
||||
_addDirToJar($srcdir, $srcdir, $zip, $compress);
|
||||
|
||||
print "Saving zip file...\n";
|
||||
my $status = $zip->writeToFileNamed($jarpath);
|
||||
if ($status == 0) {
|
||||
print "Zipping completed successfully\n";
|
||||
} else {
|
||||
print "Error saving zip file\n";
|
||||
}
|
||||
|
||||
# set the file type/creator to something reasonable
|
||||
MacPerl::SetFileInfo("ZIP ", "ZIP ", $jarpath);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# printZipContents
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
sub printZipContents($)
|
||||
{
|
||||
my($zip) = @_;
|
||||
|
||||
my(@members) = $zip->memberNames();
|
||||
|
||||
print "Zip contains:\n";
|
||||
|
||||
my($member);
|
||||
foreach $member (@members)
|
||||
{
|
||||
print " $member\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# safeSaveJarFile
|
||||
#
|
||||
# Archive::Zip has a problem where you cannot save a zip file on top of
|
||||
# an existing zip file that it has open, because it holds references
|
||||
# into that zip. So we have to save to a temp file, then do a swap.
|
||||
#
|
||||
# Note that the zip will become invalid after this operation.
|
||||
# If you want to do further operations on it, you'll have to reread it.
|
||||
#-------------------------------------------------------------------------------
|
||||
sub safeSaveJarFile($$)
|
||||
{
|
||||
my($zip, $full_dest_path) = @_;
|
||||
|
||||
my($temp_file_name) = $full_dest_path."_temp";
|
||||
|
||||
($zip->writeToFileNamed($temp_file_name) == Archive::Zip::AZ_OK) || die "Error: died writing jar to temp file $temp_file_name\n";
|
||||
|
||||
unlink $full_dest_path;
|
||||
|
||||
(rename $temp_file_name, $full_dest_path) || die "Error: Failed to rename $temp_file_name\n";
|
||||
|
||||
MacPerl::SetFileInfo("ZIP ", "ZIP ", $full_dest_path);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# addToJarFile
|
||||
#
|
||||
# Add a file to a jar file
|
||||
#
|
||||
# Parameters:
|
||||
# 1. Jar ID. Unix path of jar file inside chrome.
|
||||
# 2. Abs path to jar.mn file (i.e. source) (mac breaks)
|
||||
# 3. File source, relative to jar.mn path (mac breaks)
|
||||
# 4. Abs path to the resulting .jar file (mac breaks)
|
||||
# 5. Relative file path within the jar (unix breaks)
|
||||
# 6. Reference to hash of jar files
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
sub addToJarFile($$$$$$$)
|
||||
{
|
||||
my($jar_id, $jar_man_dir, $file_src, $jar_path, $file_jar_path, $override, $jars) = @_;
|
||||
|
||||
# print "addToJarFile with:\n $jar_man_dir\n $file_src\n $jar_path\n $file_jar_path\n";
|
||||
|
||||
unless ($jar_path =~ m/(.+:)([^:]+)$/) { die "Error: Bad jar path $jar_path\n"; }
|
||||
|
||||
my($target_dir) = $1;
|
||||
my($jar_name) = $2;
|
||||
|
||||
$target_dir =~ s/[^:]+$//;
|
||||
|
||||
# print "¥ $target_dir $jar_name\n";
|
||||
|
||||
# find the source file
|
||||
my($src) = $jar_man_dir.":".$file_src;
|
||||
if ((!-e $src) && ($file_src =~ m/.+:([^:]+)$/)) # src does not exist. Fall back to looking for src in jar.mn dir
|
||||
{
|
||||
$file_src = $1;
|
||||
$src = $jar_man_dir.":".$file_src;
|
||||
|
||||
if (!-e $src) {
|
||||
die "Error: Can't find chrome file $src\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($main::options{chrome_jars})
|
||||
{
|
||||
my($zip) = $jars->{$jar_id};
|
||||
unless ($zip) { die "Error: Can't find Zip entry for $jar_id\n"; }
|
||||
|
||||
# print "Adding $file_src to jar file $jar_path at $file_jar_path\n";
|
||||
my($member) = Archive::Zip::Member->newFromFile($src);
|
||||
unless ($member) { die "Error: Failed to create zip file member $src\n"; }
|
||||
|
||||
$member->fileName($file_jar_path);
|
||||
|
||||
my($compress) = 1;
|
||||
if ($compress) {
|
||||
$member->desiredCompressionMethod(Archive::Zip::COMPRESSION_DEFLATED);
|
||||
$member->desiredCompressionLevel(Archive::Zip::COMPRESSION_LEVEL_DEFAULT); # defaults to 6
|
||||
} else {
|
||||
$member->desiredCompressionMethod(Archive::Zip::COMPRESSION_STORED);
|
||||
}
|
||||
|
||||
my($old_member) = $zip->memberNamed($file_jar_path);
|
||||
|
||||
if ($override)
|
||||
{
|
||||
if ($old_member)
|
||||
{
|
||||
# print "Overriding $file_jar_path in jar file $jar_id\n";
|
||||
# need to compare mod dates or use the + here
|
||||
$zip->removeMember($old_member);
|
||||
}
|
||||
|
||||
$zip->addMember($member);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($old_member)
|
||||
{
|
||||
#compare dates here
|
||||
my($member_moddate) = $old_member->lastModTime();
|
||||
my($file_moddate) = GetFileModDate($src);
|
||||
|
||||
if ($file_moddate > $member_moddate)
|
||||
{
|
||||
print "Updating older file $file_jar_path in $jar_id\n";
|
||||
$zip->removeMember($old_member);
|
||||
$zip->addMember($member);
|
||||
}
|
||||
else
|
||||
{
|
||||
print "File $file_jar_path in $jar_id is more recent. Not updating.\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$zip->addMember($member);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($main::options{chrome_files}) # we install raw files too
|
||||
{
|
||||
my($rel_path) = $file_jar_path;
|
||||
$rel_path =~ s|/|:|g; # slash to colons
|
||||
|
||||
my($dir_name) = $jar_name;
|
||||
$dir_name =~ s/\.jar$//;
|
||||
|
||||
my($dst) = $target_dir.$dir_name.":".$rel_path;
|
||||
|
||||
# print "Aliassing $src\n to\n$dst\n";
|
||||
if ($override)
|
||||
{
|
||||
unlink $dst;
|
||||
MakeAlias($src, $dst); # don't check errors, otherwise we fail on replacement
|
||||
}
|
||||
else
|
||||
{
|
||||
if (-e $dst)
|
||||
{
|
||||
#compare dates here
|
||||
my($dst_moddate) = GetFileModDate($dst);
|
||||
my($file_moddate) = GetFileModDate($src);
|
||||
|
||||
if ($file_moddate > $dst_moddate)
|
||||
{
|
||||
print "Updating older file $rel_path in $dir_name\n";
|
||||
unlink $dst;
|
||||
MakeAlias($src, $dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
print "File $file_jar_path in $jar_id is more recent. Not updating.\n";
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
MakeAlias($src, $dst);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# setupJarFile
|
||||
#
|
||||
# setup a zip for writing
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
sub setupJarFile($$$)
|
||||
{
|
||||
my($jar_id, $dest_path, $jar_hash) = @_;
|
||||
|
||||
# print "Creating jar file $jar_id at $jar_path\n";
|
||||
|
||||
my($jar_file) = $jar_id;
|
||||
$jar_file =~ s|/|:|g; # slash to colons
|
||||
my($full_jar_path) = full_path_to($dest_path.":".$jar_file);
|
||||
|
||||
if ($main::options{chrome_jars})
|
||||
{
|
||||
my($zip) = $jar_hash->{$jar_id};
|
||||
if (!$zip) # if we haven't made it already, do so
|
||||
{
|
||||
my($zip) = Archive::Zip->new();
|
||||
$jar_hash->{$jar_id} = $zip;
|
||||
|
||||
# does the jar file exist already? If so, read it in
|
||||
if (-e $full_jar_path)
|
||||
{
|
||||
print "Reading in jar file $jar_id\n";
|
||||
if ($zip->read($full_jar_path) != Archive::Zip::AZ_OK) { die "Error: Failed to re-read $full_jar_path\n"; }
|
||||
|
||||
# printZipContents($zip);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# installing files.
|
||||
# nothing to do. MakeAlias creates dirs as needed.
|
||||
|
||||
# add this jar to the list
|
||||
$jar_hash->{$jar_id} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# closeJarFile
|
||||
#
|
||||
# We're done with this jar file _for this jar.mn_. We may add more entries
|
||||
# to it later, so keep it open in the hash.
|
||||
#-------------------------------------------------------------------------------
|
||||
sub closeJarFile($$)
|
||||
{
|
||||
my($jar_path, $jar_hash) = @_;
|
||||
|
||||
# print "Closing jar file $jar_path\n";
|
||||
|
||||
if ($main::options{chrome_jars})
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
# installing files.
|
||||
# nothing to do
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# WriteOutJarFiles
|
||||
#
|
||||
# Now we dump out the jars
|
||||
#-------------------------------------------------------------------------------
|
||||
sub WriteOutJarFiles($$)
|
||||
{
|
||||
my($chrome_dir, $jars) = @_;
|
||||
|
||||
unless ($main::options{chrome_jars}) { return; }
|
||||
|
||||
my($full_chrome_path) = full_path_to($chrome_dir);
|
||||
|
||||
my($key);
|
||||
foreach $key (keys %$jars)
|
||||
{
|
||||
my($zip) = $jars->{$key};
|
||||
|
||||
my($rel_path) = $key;
|
||||
$rel_path =~ s/\//:/g;
|
||||
|
||||
my($output_path) = $full_chrome_path.":".$rel_path;
|
||||
|
||||
print "Writing zip file $key to $output_path\n";
|
||||
|
||||
# ensure the target dirs exist
|
||||
my($path) = $output_path;
|
||||
$path =~ s/[^:]+$//;
|
||||
mkpath($path);
|
||||
|
||||
# unlink $output_path; # remove any existing jar
|
||||
safeSaveJarFile($zip, $output_path);
|
||||
# $zip is invalid after this operation, so nuke it here
|
||||
$jars->{$key} = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# registerChromePackage
|
||||
#
|
||||
# Enter a chrome package into the installed-chrome.txt file
|
||||
#-------------------------------------------------------------------------------
|
||||
sub registerChromePackage($$$$$$)
|
||||
{
|
||||
my($jar_file, $file_path, $chrome_dir, $jar_hash, $chrome_type, $pkg_name) = @_;
|
||||
|
||||
my($manifest_subdir) = $jar_file;
|
||||
$manifest_subdir =~ s/:/\//g;
|
||||
|
||||
if (index($manifest_subdir, "-unix") == -1 && index($manifest_subdir, "-win") == -1) {
|
||||
|
||||
my($chrome_entry);
|
||||
|
||||
if ($main::options{use_jars}) {
|
||||
$chrome_entry = "$chrome_type,install,url,jar:resource:/chrome/$manifest_subdir!/$chrome_type/$pkg_name";
|
||||
} else {
|
||||
$manifest_subdir =~ s/\.jar$//;
|
||||
$chrome_entry = "$chrome_type,install,url,resource:/chrome/$manifest_subdir/$chrome_type/$pkg_name";
|
||||
}
|
||||
|
||||
# print "Entering $chrome_entry in installed-chrome.txt\n";
|
||||
|
||||
# ensure chrome_dir exists
|
||||
mkpath($chrome_dir);
|
||||
|
||||
my($inst_chrome) = ${chrome_dir}.":installed-chrome.txt";
|
||||
|
||||
if (open(CHROMEFILE, "<$inst_chrome")) {
|
||||
while (<CHROMEFILE>) {
|
||||
chomp;
|
||||
if ($_ eq $chrome_entry) {
|
||||
# $chrome_entry already appears in installed-chrome.txt file
|
||||
# just update the mod date
|
||||
my $now = time;
|
||||
utime($now, $now, $inst_chrome) || die "Error: Couldn't touch $inst_chrome";
|
||||
print "+++ updating chrome $inst_chrome\n+++\t\t$chrome_entry\n";
|
||||
close(CHROMEFILE) || die "Error: can't close $inst_chrome: $!";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
close(CHROMEFILE) || die "Error: can't close $inst_chrome: $!";
|
||||
}
|
||||
open(CHROMEFILE, ">>${inst_chrome}") || die "Error: Failed to open $inst_chrome\n";
|
||||
print(CHROMEFILE "${chrome_entry}\n");
|
||||
close(CHROMEFILE) || die "Error: Failed to close $inst_chrome\n";
|
||||
print "+++ adding chrome $inst_chrome\n+++\t\t$chrome_entry\n";
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Create or add to a jar file from a jar.mn file.
|
||||
# Both arguments are relative to the mozilla root dir.
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
sub CreateJarFromManifest($$$)
|
||||
{
|
||||
my($jar_man_path, $dest_path, $jars) = @_;
|
||||
|
||||
if ($main::options{chrome_jars}) {
|
||||
print "Jarring from $jar_man_path\n";
|
||||
}
|
||||
if ($main::options{chrome_files}) {
|
||||
print "Installing files from $jar_man_path\n";
|
||||
}
|
||||
|
||||
$jar_man_path = full_path_to($jar_man_path);
|
||||
$dest_path = full_path_to($dest_path);
|
||||
|
||||
# if the jars hash is empty, nuke installed-chrome.txt
|
||||
if (! scalar(%$jars))
|
||||
{
|
||||
print "Nuking installed-chrome.txt\n";
|
||||
my($installed_chrome) = $dest_path.":installed-chrome.txt";
|
||||
# unlink $installed_chrome;
|
||||
}
|
||||
|
||||
my $jar_man_dir = "";
|
||||
my $jar_man_file = "";
|
||||
|
||||
if ($jar_man_path =~ /(.+):([^:]+)$/)
|
||||
{
|
||||
$jar_man_dir = $1; # no trailing :
|
||||
$jar_man_file = $2;
|
||||
}
|
||||
|
||||
# Keep a hash of jar files, keyed on relative jar path (e.g. "packages/core.jar")
|
||||
# Entries are open Archive::Zips (if zipping), and installed-chrome entries.
|
||||
|
||||
my($jar_id) = ""; # Current foo/bar.jar from jar.mn file
|
||||
my($jar_file) = ""; # relative path to jar file (from $dest_path), with mac separators
|
||||
my($full_jar_path);
|
||||
|
||||
open(FILE, "<$jar_man_path") || die "Error: could not open \"$jar_man_path\": $!";
|
||||
while (<FILE>)
|
||||
{
|
||||
my($line) = $_;
|
||||
chomp($line);
|
||||
|
||||
# print "$line\n";
|
||||
|
||||
if ($line =~ /^\s*\#.*$/) { # skip comments
|
||||
next;
|
||||
}
|
||||
|
||||
if ($line =~/^([\w\d.\-\_\\\/]+)\:\s*$/) # line start jar file entries
|
||||
{
|
||||
$jar_id = $1;
|
||||
$jar_file = $jar_id;
|
||||
$jar_file =~ s|/|:|g; # slash to colons
|
||||
$full_jar_path = $dest_path.":".$jar_file;
|
||||
|
||||
setupJarFile($jar_id, $dest_path, $jars);
|
||||
|
||||
}
|
||||
elsif ($line =~ /^(\+?)\s+([\w\d.\-\_\\\/]+)\s*(\([\w\d.\-\_\\\/]+\))?$\s*/) # jar file entry
|
||||
{
|
||||
my($override) = ($1 eq "+");
|
||||
my($file_dest) = $2;
|
||||
my($file_src) = $3;
|
||||
|
||||
if ($file_src) {
|
||||
$file_src = substr($file_src, 1, -1); #strip the ()
|
||||
} else {
|
||||
$file_src = $file_dest;
|
||||
}
|
||||
|
||||
$file_src =~ s|/|:|g;
|
||||
|
||||
if ($jar_file ne "") # if jar is open, add to jar
|
||||
{
|
||||
if ($file_dest =~ /([\w\d.\-\_]+)\/([\w\d.\-\_\\\/]+)contents.rdf/)
|
||||
{
|
||||
my $chrome_type = $1;
|
||||
my $pkg_name = $2;
|
||||
registerChromePackage($jar_file, $file_dest, $dest_path, $jars, $chrome_type, $pkg_name);
|
||||
}
|
||||
|
||||
addToJarFile($jar_id, $jar_man_dir, $file_src, $full_jar_path, $file_dest, $override, $jars);
|
||||
}
|
||||
else
|
||||
{
|
||||
die "Error: bad jar.mn format at $line\n";
|
||||
}
|
||||
}
|
||||
elsif ($line =~ /^\s*$/ ) # blank line
|
||||
{
|
||||
if ($jar_file ne "") #if a jar file is open, close it
|
||||
{
|
||||
closeJarFile($full_jar_path, $jars);
|
||||
|
||||
$jar_file = "";
|
||||
$full_jar_path = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close(FILE);
|
||||
|
||||
if ($jar_file ne "") #if a jar file is open, close it
|
||||
{
|
||||
closeJarFile($full_jar_path, $jars);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -1,228 +0,0 @@
|
||||
#!perl -w
|
||||
package Moz::MacCVS;
|
||||
|
||||
# package Mac::Apps::MacCVS; this should really be the name of the package
|
||||
# but due to our directory hierarchy in mozilla, I am not doing it
|
||||
|
||||
require 5.004;
|
||||
require Exporter;
|
||||
|
||||
use strict;
|
||||
use Exporter;
|
||||
|
||||
use vars qw($VERSION @ISA @EXPORT);
|
||||
|
||||
use Cwd;
|
||||
|
||||
use File::Basename;
|
||||
|
||||
use Mac::StandardFile;
|
||||
use Mac::AppleEvents;
|
||||
use Mac::AppleEvents::Simple;
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(new describe checkout update);
|
||||
$VERSION = "1.00";
|
||||
|
||||
# If you want to understand the gobbldeygook that's used to build Apple Events,
|
||||
# you should start by reading the AEGizmos documentation.
|
||||
|
||||
|
||||
# Architecture:
|
||||
# cvs session object:
|
||||
# name - session name
|
||||
# session_file - session file
|
||||
#
|
||||
#
|
||||
|
||||
my($last_error) = 0;
|
||||
my($gAppSig) = 'Mcvs'; # MacCVS Pro
|
||||
|
||||
#
|
||||
# utility routines
|
||||
#
|
||||
|
||||
|
||||
sub _checkForEventError($)
|
||||
{
|
||||
my($evt) = @_;
|
||||
|
||||
if ($evt->{ERRNO} != 0)
|
||||
{
|
||||
print STDERR "Error. Script returned '$evt->{ERROR} (error $evt->{ERRNO})\n";
|
||||
$last_error = $evt->{ERRNO};
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1; # success
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Session object methods
|
||||
#
|
||||
|
||||
sub new
|
||||
{
|
||||
my ( $proto, $session_file) = @_;
|
||||
my $class = ref($proto) || $proto;
|
||||
my $self = {};
|
||||
|
||||
if ( defined($session_file) && ( -e $session_file) )
|
||||
{
|
||||
$self->{"name"} = basename( $session_file );
|
||||
$self->{"session_file"} = $session_file;
|
||||
bless $self, $class;
|
||||
return $self;
|
||||
}
|
||||
else
|
||||
{
|
||||
print STDERR "MacCVS->new cvs file < $session_file > does not exist\n";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
# makes sure that the session is open
|
||||
# assertSessionOpen()
|
||||
# returns 1 on success
|
||||
sub assertSessionOpen()
|
||||
{
|
||||
my ($self) = shift;
|
||||
|
||||
$last_error = 0;
|
||||
|
||||
my($prm) =
|
||||
q"'----':obj {form:name, want:type(alis), seld:TEXT(@), from:'null'()}";
|
||||
|
||||
my($evt) = do_event(qw/aevt odoc/, $gAppSig, $prm, $self->{session_file});
|
||||
return _checkForEventError($evt);
|
||||
}
|
||||
|
||||
# prints the cvs object, used mostly for debugging
|
||||
sub describe
|
||||
{
|
||||
my($self) = shift;
|
||||
$last_error = 0;
|
||||
print "MacCVS:: name: ", $self->{name}, " session file: ", $self->{session_file}, "\n";
|
||||
}
|
||||
|
||||
# checkout( self, module, revision, date)
|
||||
# MacCVS checkout command
|
||||
# returns 1 on success.
|
||||
sub checkout()
|
||||
{
|
||||
my($self, $module, $revision, $date ) = @_;
|
||||
unless( defined ($module) ) { $module = ""; } # get rid of the pesky undefined warnings
|
||||
unless( defined ($revision) ) { $revision = ""; }
|
||||
unless( defined ($date) ) { $date = ""; }
|
||||
|
||||
$last_error = 0;
|
||||
|
||||
$self->assertSessionOpen() || die "Error: failed to open MacCVS session file at $self->{session_file}\n";
|
||||
|
||||
my($revstring) = ($revision ne "") ? $revision : "(none)";
|
||||
my($datestring) = ($date ne "") ? $date : "(none)";
|
||||
|
||||
print "Checking out $module with revision $revstring, date $datestring\n";
|
||||
|
||||
my($prm) =
|
||||
q"'----':obj {form:name, want:type(docu), seld:TEXT(@), from:'null'()}, ".
|
||||
q"modl:'TEXT'(@), tagr:'TEXT'(@), tagd:'TEXT'(@) ";
|
||||
|
||||
my($evt) = do_event(qw/MCvs cout/, $gAppSig, $prm, $self->{name}, $module, $revision, $date);
|
||||
return _checkForEventError($evt);
|
||||
}
|
||||
|
||||
|
||||
# update( self, branch tag, list of paths)
|
||||
# MacCVS udate command
|
||||
# returns 1 on success.
|
||||
# NOTE: MacCVS Pro does not correctly support this stuff yet (as of version 2.7d5).
|
||||
sub update()
|
||||
{
|
||||
my($self, $branch, $paths ) = @_;
|
||||
|
||||
$last_error = 0;
|
||||
|
||||
$self->assertSessionOpen() || die "Error: failed to open MacCVS session file at $self->{session_file}\n";
|
||||
|
||||
if ($branch eq "HEAD") {
|
||||
$branch = "";
|
||||
}
|
||||
|
||||
my($paths_list) = "";
|
||||
|
||||
my($path);
|
||||
foreach $path (@$paths)
|
||||
{
|
||||
if ($paths_list ne "") {
|
||||
$paths_list = $paths_list.", ";
|
||||
}
|
||||
|
||||
$paths_list = $paths_list."Ò".$path."Ó";
|
||||
}
|
||||
|
||||
my($prm) =
|
||||
q"'----':obj {form:name, want:type(docu), seld:TEXT(@), from:'null'()}, ".
|
||||
q"tagr:'TEXT'(@), tFls:[";
|
||||
|
||||
$prm = $prm.$paths_list."]";
|
||||
|
||||
my($evt) = do_event(qw/MCvs updt/, $gAppSig, $prm, $self->{name}, $branch);
|
||||
return _checkForEventError($evt);
|
||||
};
|
||||
|
||||
|
||||
sub getLastError()
|
||||
{
|
||||
return $last_error;
|
||||
}
|
||||
|
||||
1;
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
MacCVS - Interface to MacCVS
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use MacCVS;
|
||||
$session = MacCVS->new( <session_file_path>) || die "cannot create session";
|
||||
$session->checkout([module] [revision] [date]) || die "Could not check out";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This is a MacCVS interface for talking to MacCVS Pro client.
|
||||
MacCVSSession is the class used to manipulate the session
|
||||
|
||||
=item new
|
||||
MacCVS->new( <cvs session file path>);
|
||||
|
||||
Creates a new session. Returns undef on failure.
|
||||
|
||||
=item checkout( <module> [revision] [date] )
|
||||
|
||||
cvs checkout command. Revision and date are optional
|
||||
returns 0 on failure
|
||||
|
||||
=cut
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
=over
|
||||
|
||||
=item MacCVS Home Page
|
||||
|
||||
http://www.maccvs.org/
|
||||
|
||||
=back
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
Aleks Totic atotic@netscape.com
|
||||
Simon Fraser sfraser@netscape.com
|
||||
|
||||
=cut
|
||||
|
||||
__END__
|
||||
@@ -1,603 +0,0 @@
|
||||
=head1 NAME
|
||||
|
||||
B<Moz> - routines for automating CodeWarrior builds, and some extra-curricular
|
||||
activities related to building Mozilla
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use Moz;
|
||||
|
||||
OpenErrorLog(":::BuildLog");
|
||||
StopForErrors();
|
||||
|
||||
$Moz::QUIET = 1;
|
||||
InstallFromManifest(":projects:MANIFEST", $dist_dir);
|
||||
|
||||
BuildProjectClean(":projects:SomeProject.mcp", "SomeTarget");
|
||||
MakeAlias(":projects:SomeProject.shlb", $dist_dir);
|
||||
|
||||
DontStopForErrors();
|
||||
|
||||
BuildProject(":projects:SomeOtherProject.mcp", "SomeTarget");
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<Moz> comprises the routines needed to slap CodeWarrior around, force it
|
||||
to build a sequence of projects, report the results, and a few other things.
|
||||
This module should only contain functions that are generic to any build,
|
||||
not just the Mozilla build.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
package Moz::Moz;
|
||||
require Exporter;
|
||||
|
||||
use Cwd;
|
||||
|
||||
use File::Copy;
|
||||
use File::Path;
|
||||
use File::Basename;
|
||||
|
||||
use Mac::Types;
|
||||
use Mac::Events;
|
||||
use Mac::Processes;
|
||||
|
||||
use ExtUtils::Manifest 'maniread';
|
||||
|
||||
use Moz::CodeWarriorLib;
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
|
||||
@EXPORT = qw( LaunchCodeWarrior
|
||||
GetCodeWarriorRelativePath
|
||||
current_directory
|
||||
full_path_to
|
||||
DoBuildProject
|
||||
ImportXMLProject
|
||||
ExportProjectToXML
|
||||
OpenErrorLog
|
||||
MakeAlias
|
||||
GetFileModDate
|
||||
StopForErrors
|
||||
DontStopForErrors
|
||||
InstallFromManifest
|
||||
InstallResources
|
||||
RedirectOutputToFile
|
||||
Delay
|
||||
ActivateApplication
|
||||
IsProcessRunning);
|
||||
|
||||
@EXPORT_OK = qw(CloseErrorLog QUIET);
|
||||
|
||||
|
||||
sub current_directory()
|
||||
{
|
||||
my $current_directory = cwd();
|
||||
chop($current_directory) if ( $current_directory =~ m/:$/ );
|
||||
return $current_directory;
|
||||
}
|
||||
|
||||
sub full_path_to($)
|
||||
{
|
||||
my ($path) = @_;
|
||||
if ( $path =~ m/^[^:]+$/ )
|
||||
{
|
||||
$path = ":" . $path;
|
||||
}
|
||||
|
||||
if ( $path =~ m/^:/ )
|
||||
{
|
||||
$path = current_directory() . $path;
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
$logging = 0;
|
||||
$recent_errors_file = "";
|
||||
$stop_on_1st_error = 1;
|
||||
$QUIET = 0;
|
||||
|
||||
|
||||
|
||||
=head2 Logging all the errors and warnings - C<OpenErrorLog($log_file)>, C<CloseErrorLog()>
|
||||
|
||||
The warnings and errors generated in the course of building projects can be logged to a file.
|
||||
Tinderbox uses this facility to show why a remote build failed.
|
||||
|
||||
Logging is off by default.
|
||||
Start logging at any point in your build process with C<OpenErrorLog($log_file)>.
|
||||
Stop with C<CloseErrorLog()>.
|
||||
You never need to close the log explicitly, unless you want to just log a couple of projects in the middle of a big list.
|
||||
C<CloseErrorLog()> is not exported by default.
|
||||
|
||||
=cut
|
||||
|
||||
sub CloseErrorLog()
|
||||
{
|
||||
if ( $logging )
|
||||
{
|
||||
close(ERROR_LOG);
|
||||
$logging = 0;
|
||||
StopForErrors() if $stop_on_1st_error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
sub OpenErrorLog($)
|
||||
{
|
||||
my ($log_file) = @_;
|
||||
|
||||
CloseErrorLog();
|
||||
if ( $log_file )
|
||||
{
|
||||
$log_file = full_path_to($log_file);
|
||||
|
||||
open(ERROR_LOG, ">$log_file") || die "Error: Can't open $log_file\n";
|
||||
MacPerl::SetFileInfo("CWIE", "TEXT", $log_file);
|
||||
|
||||
$log_file =~ m/.+:(.+)/;
|
||||
$recent_errors_file = full_path_to("$1.part");
|
||||
$logging = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
=head2 Stopping before it's too late - C<StopForErrors()>, C<DontStopForErrors()>
|
||||
|
||||
When building a long list of projects, you decide whether to continue building subsequent projects when one fails.
|
||||
By default, your build script will C<die> after the first project that generates an error while building.
|
||||
Change this behavior with C<DontStopForErrors()>.
|
||||
Re-enable it with C<StopForErrors()>.
|
||||
|
||||
=cut
|
||||
|
||||
sub StopForErrors()
|
||||
{
|
||||
$stop_on_1st_error = 1;
|
||||
|
||||
# Can't stop for errors unless we notice them.
|
||||
# Can't notice them unless we are logging.
|
||||
# If the user didn't explicitly request logging, log to a temporary file.
|
||||
|
||||
if ( ! $recent_errors_file )
|
||||
{
|
||||
OpenErrorLog("${TMPDIR}BuildResults");
|
||||
}
|
||||
}
|
||||
|
||||
sub DontStopForErrors()
|
||||
{
|
||||
$stop_on_1st_error = 0;
|
||||
}
|
||||
|
||||
sub log_message($)
|
||||
{
|
||||
if ( $logging )
|
||||
{
|
||||
my ($message) = @_;
|
||||
print ERROR_LOG $message;
|
||||
}
|
||||
}
|
||||
|
||||
sub log_message_with_time($)
|
||||
{
|
||||
if ( $logging )
|
||||
{
|
||||
my ($message) = @_;
|
||||
my $time_stamp = localtime();
|
||||
log_message("$message ($time_stamp)\n");
|
||||
}
|
||||
}
|
||||
|
||||
sub log_recent_errors($)
|
||||
{
|
||||
my ($project_name) = @_;
|
||||
my $found_errors = 0;
|
||||
|
||||
if ( $logging )
|
||||
{
|
||||
open(RECENT_ERRORS, "<$recent_errors_file");
|
||||
|
||||
while( <RECENT_ERRORS> )
|
||||
{
|
||||
if ( /^Error/ || /^CouldnÕt find project file/ || /^Link Error/ )
|
||||
{
|
||||
# if (!$found_errors)
|
||||
# print $_;
|
||||
$found_errors = 1;
|
||||
}
|
||||
print ERROR_LOG $_;
|
||||
}
|
||||
|
||||
close(RECENT_ERRORS);
|
||||
unlink("$recent_errors_file");
|
||||
}
|
||||
|
||||
if ( $stop_on_1st_error && $found_errors )
|
||||
{
|
||||
print ERROR_LOG "### Build failed.\n";
|
||||
die "### Errors encountered building \"$project_name\".\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub DoBuildProject($$$)
|
||||
{
|
||||
my ($project_path, $target_name, $clean_build) = @_;
|
||||
$project_path = full_path_to($project_path);
|
||||
|
||||
# $project_path =~ m/.+:(.+)/;
|
||||
# my $project_name = $1;
|
||||
|
||||
log_message_with_time("### Building \"$project_path\"");
|
||||
|
||||
# Check that the given project exists
|
||||
if (! -e $project_path)
|
||||
{
|
||||
print ERROR_LOG "### Build failed.\n";
|
||||
die "### Can't find project file \"$project_path\".\n";
|
||||
}
|
||||
|
||||
print "Building \"$project_path\[$target_name\]\"\n";
|
||||
|
||||
$had_errors = Moz::CodeWarriorLib::build_project(
|
||||
$project_path, $target_name, $recent_errors_file, $clean_build
|
||||
);
|
||||
WaitNextEvent();
|
||||
|
||||
# $had_errors =
|
||||
#MacPerl::DoAppleScript(<<END_OF_APPLESCRIPT);
|
||||
# tell (load script file "$CodeWarriorLib") to BuildProject("$project_path", "$project_name", "$target_name", "$recent_errors_file", $clean_build)
|
||||
#END_OF_APPLESCRIPT
|
||||
|
||||
# Append any errors to the globally accumulated log file
|
||||
# if ( $had_errors ) # Removed this test, because we want warnings, too. -- jrm
|
||||
{
|
||||
log_recent_errors($project_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub ImportXMLProject($$)
|
||||
{
|
||||
my ($xml_path, $project_path) = @_;
|
||||
|
||||
# my ($codewarrior_ide_name) = Moz::CodeWarriorLib::getCodeWarriorIDEName();
|
||||
# my $ascript = <<EOS;
|
||||
# tell application "$codewarrior_ide_name"
|
||||
# make new (project document) as ("$project_path") with data ("$xml_path")
|
||||
# end tell
|
||||
#EOS
|
||||
# print $ascript."\n";
|
||||
# my($result) = MacPerl::DoAppleScript($ascript);
|
||||
# unless ($result) { die "Error: ImportXMLProject AppleScript failed $^E $result\n"; }
|
||||
#
|
||||
|
||||
my($import_error) = Moz::CodeWarriorLib::import_project($xml_path, $project_path);
|
||||
if ($import_error ne "") {
|
||||
die "Error: ImportXMLProject failed with error $import_error\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub ExportProjectToXML($$)
|
||||
{
|
||||
my ($project_path, $xml_path) = @_;
|
||||
|
||||
my (@suffix_list) = (".mcp");
|
||||
my ($project_name, $project_dir, $suffix) = fileparse($project_path, @suffix_list);
|
||||
if ($suffix eq "") { die "Project: $project_path doesn't look like a project file.\n"; }
|
||||
|
||||
if (-e $xml_path) {
|
||||
print "$xml_path exists - not exporting $project_path\n";
|
||||
}
|
||||
else {
|
||||
print "Exporting $project_path to $xml_path\n";
|
||||
my($export_error) = Moz::CodeWarriorLib::export_project($project_path, $xml_path);
|
||||
if ($export_error ne "") {
|
||||
die "Error: export_project failed with error '$export_error'\n";
|
||||
}
|
||||
|
||||
if (! -e $xml_path) {
|
||||
die "Error: XML export to $xml_path failed\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
=head2 Miscellaneous
|
||||
|
||||
C<MakeAlias($old_file, $new_file)> functions like C<symlink()>, except with better argument defaulting and more explicit error messages.
|
||||
|
||||
=cut
|
||||
|
||||
sub MakeAlias($$)
|
||||
{
|
||||
my ($old_file, $new_file) = @_;
|
||||
|
||||
# if the directory to hold $new_file doesn't exist, create it
|
||||
if ( ($new_file =~ m/(.+:)/) && !-d $1 )
|
||||
{
|
||||
mkpath($1);
|
||||
}
|
||||
|
||||
# if a leaf name wasn't specified for $new_file, use the leaf from $old_file
|
||||
if ( ($new_file =~ m/:$/) && ($old_file =~ m/.+:(.+)/) )
|
||||
{
|
||||
$new_file .= $1;
|
||||
}
|
||||
|
||||
my $message = "Can't create a Finder alias (at \"$new_file\")\n for \"$old_file\"; because ";
|
||||
|
||||
die "Error: $message \"$old_file\" doesn't exist.\n" unless -e $old_file;
|
||||
die "Error: $message I won't replace an existing (non-alias) file with an alias.\n" if ( -e $new_file && ! -l $new_file );
|
||||
|
||||
# now: $old_file exists; $new_file doesn't (or else, is an alias already)
|
||||
|
||||
if ( -l $new_file )
|
||||
{
|
||||
# ...then see if it already points to $old_file
|
||||
my $current_target = full_path_to(readlink($new_file));
|
||||
my $new_target = full_path_to($old_file);
|
||||
|
||||
return if ( $current_target eq $new_target );
|
||||
# if the desired alias already exists and points to the right thing, then we're done
|
||||
|
||||
unlink $new_file;
|
||||
}
|
||||
|
||||
symlink($old_file, $new_file) || die "Error: $message symlink returned an unexpected error.\n";
|
||||
}
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
C<InstallFromManifest()>
|
||||
|
||||
=cut
|
||||
|
||||
sub InstallFromManifest($;$$)
|
||||
{
|
||||
my ($manifest_file, $dest_dir, $flat) = @_;
|
||||
|
||||
$flat = 0 unless defined($flat); # if $flat, all rel. paths in MANIFEST get aliased to the root of $dest_dir
|
||||
|
||||
$dest_dir ||= ":";
|
||||
|
||||
$manifest_file =~ m/(.+):/;
|
||||
my $source_dir = $1;
|
||||
|
||||
chop($dest_dir) if $dest_dir =~ m/:$/;
|
||||
|
||||
#Mac::Events->import();
|
||||
WaitNextEvent();
|
||||
if ($flat)
|
||||
{
|
||||
print "Doing manifest on \"$manifest_file\" FLAT\n" unless $QUIET;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Doing manifest on \"$manifest_file\"\n" unless $QUIET;
|
||||
}
|
||||
|
||||
my $read = maniread(full_path_to($manifest_file));
|
||||
foreach $file (keys %$read)
|
||||
{
|
||||
next unless $file;
|
||||
|
||||
$subdir = ":";
|
||||
if (!$flat && ($file =~ /:.+:/ ))
|
||||
{
|
||||
$subdir = $&;
|
||||
}
|
||||
|
||||
$file = ":$file" unless $file =~ m/^:/;
|
||||
MakeAlias("$source_dir$file", "$dest_dir$subdir");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
C<InstallResources()>
|
||||
|
||||
=cut
|
||||
|
||||
# parameters are path to MANIFEST file, destination dir, true (to make copies) or false (to make aliases)
|
||||
sub InstallResources($;$;$)
|
||||
{
|
||||
my ($manifest_file, $dest_dir, $copy_files) = @_;
|
||||
|
||||
$dest_dir ||= ":";
|
||||
mkpath($dest_dir) if !-d $dest_dir;
|
||||
|
||||
$manifest_file =~ m/(.+):/;
|
||||
my $source_dir = $1;
|
||||
|
||||
chop($dest_dir) if $dest_dir =~ m/:$/;
|
||||
|
||||
WaitNextEvent();
|
||||
print "Installing resources from \"$manifest_file\"\n" unless $QUIET;
|
||||
|
||||
my $read = maniread(full_path_to($manifest_file));
|
||||
foreach $file (keys %$read)
|
||||
{
|
||||
next unless $file;
|
||||
|
||||
if ($copy_files)
|
||||
{
|
||||
copy("$source_dir:$file", "$dest_dir:$file");
|
||||
}
|
||||
else
|
||||
{
|
||||
MakeAlias("$source_dir:$file", "$dest_dir:$file");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// Delay
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub Delay($)
|
||||
{
|
||||
my ($delay_seconds) = @_;
|
||||
|
||||
$now = time;
|
||||
|
||||
$exit_time = $now + $delay_seconds;
|
||||
|
||||
while ($exit_time > $now) {
|
||||
$now = time;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GetFileModDate
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub GetFileModDate($)
|
||||
{
|
||||
my($filePath)=@_;
|
||||
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
|
||||
$atime,$mtime,$ctime,$blksize,$blocks) = stat($filePath);
|
||||
return $mtime;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// LaunchCodeWarrior
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub LaunchCodeWarrior($)
|
||||
{
|
||||
my($idepath_file) = @_; # full path to IDE location file
|
||||
my($cur_dir) = cwd();
|
||||
|
||||
# this both launches and writes the IDE path file
|
||||
Moz::CodeWarriorLib::activate($idepath_file);
|
||||
|
||||
chdir($cur_dir);
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GetCodeWarriorRelativePath
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub GetCodeWarriorRelativePath($)
|
||||
{
|
||||
my($rel_path) = @_;
|
||||
return Moz::CodeWarriorLib::getCodeWarriorPath($rel_path);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// RedirectOutputToFile
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub RedirectOutputToFile($)
|
||||
{
|
||||
my($log_file) = @_;
|
||||
|
||||
# ensure that folders in the path exist
|
||||
my($logdir) = "";
|
||||
my($logfile) = $log_file;
|
||||
|
||||
if ($log_file =~ /(.+?:)([^:]+)$/) # ? for non-greedy match
|
||||
{
|
||||
$logdir = $1;
|
||||
$logfile = $2;
|
||||
|
||||
mkpath($logdir);
|
||||
}
|
||||
|
||||
print "Output is now being redirected to the file '$log_file'\n";
|
||||
|
||||
open(STDOUT, "> $log_file") || die "Can't redirect stdout";
|
||||
open(STDERR, ">&STDOUT") || die "Can't dup stdout";
|
||||
select(STDERR); $| = 1; # make unbuffered
|
||||
select(STDOUT); $| = 1; # make unbuffered
|
||||
|
||||
MacPerl::SetFileInfo("CWIE", "TEXT", $log_file);
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// ActivateApplication
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub ActivateApplication($)
|
||||
{
|
||||
my ($appSignature) = @_;
|
||||
my ($psi, $found);
|
||||
my ($appPSN);
|
||||
|
||||
$found = 0;
|
||||
|
||||
foreach $psi (values(%Process))
|
||||
{
|
||||
if ($psi->processSignature() eq $appSignature)
|
||||
{
|
||||
$appPSN = $psi->processNumber();
|
||||
$found = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
if ($found == 0 || SameProcess($appPSN, GetFrontProcess()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SetFrontProcess($appPSN);
|
||||
|
||||
while (GetFrontProcess() != $appPSN)
|
||||
{
|
||||
WaitNextEvent();
|
||||
}
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// IsProcessRunning
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub IsProcessRunning($)
|
||||
{
|
||||
my($processName, $psn, $psi) = @_;
|
||||
while ( ($psn, $psi) = each(%Process) ) {
|
||||
if ($psi->processName eq $processName) { return 1; }
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
Scott Collins <scc@netscape.com>, Simon Fraser <sfraser@netscape.com>, Chris Yeh <cyeh@netscape.com>
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
BuildMozillaDebug.pl (et al), BuildList.pm, CodeWarriorLib (an AppleScript library)
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
The contents of this file are subject to the Netscape 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/NPL/
|
||||
|
||||
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 Mozilla Communicator client code, released
|
||||
March 31, 1998.
|
||||
|
||||
The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
=cut
|
||||
@@ -1,272 +0,0 @@
|
||||
|
||||
package Moz::Prefs;
|
||||
|
||||
require 5.004;
|
||||
require Exporter;
|
||||
|
||||
# Package that attempts to read a file from the Preferences folder,
|
||||
# and get build settings out of it
|
||||
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use File::Path;
|
||||
|
||||
use Mac::Files;
|
||||
|
||||
use vars qw(@ISA @EXPORT);
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(ReadMozUserPrefs);
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# GetPrefsFolder
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
sub GetPrefsFolder()
|
||||
{
|
||||
my($prefs_folder) = FindFolder(kOnSystemDisk, kPreferencesFolderType, 1);
|
||||
return $prefs_folder.":Mozilla build prefs";
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# SetArrayValue
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
sub SetArrayValue($$$)
|
||||
{
|
||||
my($array_ref, $index1, $index2) = @_;
|
||||
|
||||
my($index);
|
||||
foreach $index (@$array_ref)
|
||||
{
|
||||
if ($index->[0] eq $index1)
|
||||
{
|
||||
$index->[1] = $index2;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# WriteDefaultPrefsFile
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
sub WriteDefaultPrefsFile($)
|
||||
{
|
||||
my($file_path) = @_;
|
||||
|
||||
my($file_contents);
|
||||
$file_contents = <<'EOS';
|
||||
% You can use this file to customize the Mozilla build system.
|
||||
% The following kinds of lines are allowable:
|
||||
% Comment lines, which start with a '%' in the first column
|
||||
% Lines which modify the default build settings. For the list of flags,
|
||||
% see MozBuildFlags.pm. Examples are:
|
||||
%
|
||||
% build pull 0 % don't pull
|
||||
% options mng 1 % turn mng on
|
||||
%
|
||||
% Line containing the special 'buildfrom' flag, which specifies
|
||||
% where to start the build. Example:
|
||||
%
|
||||
% buildfrom nglayout % where to start the build
|
||||
%
|
||||
% Lines which specify the location of the files used to store paths
|
||||
% to the CodeWarrior IDE, and the MacCVS Pro session file. Note quoting
|
||||
% of paths containing whitespace. Examples:
|
||||
%
|
||||
% filepath idepath ::codewarrior.txt
|
||||
% filepath sessionpath ":Some folder:MacCVS session path.txt"
|
||||
%
|
||||
% Lines which modify the build settings like %main::DEBUG.
|
||||
% Any lines which do not match either of the above are assumed
|
||||
% to set variables on $main::. Examples:
|
||||
%
|
||||
% MOZILLA_OFFICIAL 1
|
||||
%
|
||||
EOS
|
||||
|
||||
$file_contents =~ s/%/#/g;
|
||||
|
||||
local(*PREFS_FILE);
|
||||
|
||||
open(PREFS_FILE, "> $file_path") || die "Could not write default prefs file\n";
|
||||
print PREFS_FILE ($file_contents);
|
||||
close(PREFS_FILE);
|
||||
|
||||
MacPerl::SetFileInfo("McPL", "TEXT", $file_path);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# HandlePrefSet
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
sub HandlePrefSet($$$$)
|
||||
{
|
||||
my($flags, $name, $value, $desc) = @_;
|
||||
|
||||
if (SetArrayValue($flags, $name, $value)) {
|
||||
print "Prefs set $desc flag '$name' to '$value'\n";
|
||||
} else {
|
||||
die "$desc setting '$name' is not a valid option\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# HandleBuildFromPref
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
sub HandleBuildFromPref($$)
|
||||
{
|
||||
my($build_array, $name) = @_;
|
||||
|
||||
my($setting) = 0;
|
||||
my($index);
|
||||
foreach $index (@$build_array)
|
||||
{
|
||||
if ($index->[0] eq $name) {
|
||||
$setting = 1;
|
||||
}
|
||||
|
||||
$index->[1] = $setting;
|
||||
}
|
||||
|
||||
if ($setting == 1) {
|
||||
print "Building from $name onwards, as specified by prefs\n";
|
||||
} else {
|
||||
printf "Failed to find buildfrom setting '$name'\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# ReadPrefsFile
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
sub ReadPrefsFile($$$$$)
|
||||
{
|
||||
my($file_path, $build_flags, $options_flags, $filepath_flags, $create_if_missing) = @_;
|
||||
|
||||
local(*PREFS_FILE);
|
||||
|
||||
if (open(PREFS_FILE, "< $file_path"))
|
||||
{
|
||||
print "Reading build prefs from '$file_path'\n";
|
||||
|
||||
while (<PREFS_FILE>)
|
||||
{
|
||||
my($line) = $_;
|
||||
chomp($line);
|
||||
|
||||
if ($line =~ /^\#/ || $line =~ /^\s*$/) { # ignore comments and empty lines
|
||||
next;
|
||||
}
|
||||
|
||||
if (($line =~ /^\s*([^#\s]+)\s+([^#\s]+)\s+\"(.+)\"(\s+#.+)?/) ||
|
||||
($line =~ /^\s*([^#\s]+)\s+([^#\s]+)\s+\'(.+)\'(\s+#.+)?/) ||
|
||||
($line =~ /^\s*([^#\s]+)\s+([^#\s]+)\s+([^#\s]+)(\s+#.+)?/))
|
||||
{
|
||||
my($array_name) = $1;
|
||||
my($option_name) = $2;
|
||||
my($option_value) = $3;
|
||||
|
||||
# print "Read '$array_name' '$option_name' '$option_value'\n";
|
||||
|
||||
if ($array_name eq "build")
|
||||
{
|
||||
HandlePrefSet($build_flags, $option_name, $option_value, "Build");
|
||||
}
|
||||
elsif ($array_name eq "options")
|
||||
{
|
||||
HandlePrefSet($options_flags, $option_name, $option_value, "Options");
|
||||
}
|
||||
elsif ($array_name eq "filepath" && $option_name && $option_value)
|
||||
{
|
||||
HandlePrefSet($filepath_flags, $option_name, $option_value, "Filepath");
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Unknown pref option at $line\n";
|
||||
}
|
||||
}
|
||||
elsif ($line =~ /^\s*buildfrom\s+([^#\s]+)(\s+#.+)?/)
|
||||
{
|
||||
my($build_start) = $1;
|
||||
HandleBuildFromPref($build_flags, $build_start);
|
||||
}
|
||||
elsif ($line =~ /^\s*([^#\s]+)\s+([^#\s]+)(\s+#.+)?/)
|
||||
{
|
||||
my($build_var) = $1;
|
||||
my($var_setting) = $2;
|
||||
|
||||
print "Setting \$main::$build_var to $var_setting\n";
|
||||
eval "\$main::$build_var = \"$var_setting\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Unrecognized input line at $line\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
close(PREFS_FILE);
|
||||
}
|
||||
elsif ($create_if_missing)
|
||||
{
|
||||
print "No prefs file found at $file_path; using defaults\n";
|
||||
|
||||
my($folder_path) = $file_path;
|
||||
$folder_path =~ s/[^:]+$//;
|
||||
mkpath($folder_path);
|
||||
WriteDefaultPrefsFile($file_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# ReadMozUserPrefs
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
sub ReadMozUserPrefs($$$$)
|
||||
{
|
||||
my($prefs_file_name, $build_flags, $options_flags, $filepath_flags) = @_;
|
||||
|
||||
if ($prefs_file_name eq "") { return; }
|
||||
|
||||
# if local prefs exist, just use those. Othewise, look in the prefs folder
|
||||
if (-e $prefs_file_name)
|
||||
{
|
||||
# read local prefs
|
||||
ReadPrefsFile($prefs_file_name, $build_flags, $options_flags, $filepath_flags, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
# first read prefs folder prefs
|
||||
my($prefs_path) = GetPrefsFolder();
|
||||
$prefs_path .= ":$prefs_file_name";
|
||||
|
||||
ReadPrefsFile($prefs_path, $build_flags, $options_flags, $filepath_flags, 1);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -1,932 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 mozilla.org code.
|
||||
#
|
||||
# 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):
|
||||
# Simon Fraser <sfraser@netscape.com>
|
||||
#
|
||||
|
||||
package Moz::ProjectXML;
|
||||
|
||||
require 5.004;
|
||||
require Exporter;
|
||||
|
||||
use strict;
|
||||
use Exporter;
|
||||
|
||||
use Cwd;
|
||||
use XML::DOM;
|
||||
|
||||
use vars qw(@ISA @EXPORT);
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(
|
||||
ParseXMLDocument
|
||||
DisposeXMLDocument
|
||||
WriteXMLDocument
|
||||
CleanupPro5XML
|
||||
GetTargetsList
|
||||
CloneTarget
|
||||
SetAsSharedLibraryTarget
|
||||
SetAsStaticLibraryTarget
|
||||
AddTarget
|
||||
RemoveTarget
|
||||
GetTargetSetting
|
||||
SetTargetSetting
|
||||
getChildElementTextContents
|
||||
);
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# A module for reading, manipulating, and writing XML-format CodeWarrior project files.
|
||||
#
|
||||
# Sample usage:
|
||||
#
|
||||
# use ProjectXML;
|
||||
#
|
||||
# my $doc = ProjectXML::ParseXMLDocument("Test.mcp.xml");
|
||||
# ProjectXML::CloneTarget($doc, "Test.shlb", "Test.lib");
|
||||
# ProjectXML::SetAsStaticLibraryTarget($doc, "Test.lib", "TestOutput.lib");
|
||||
# ProjectXML::WriteXMLDocument($doc, "Test_out.xml");
|
||||
# ProjectXML::DisposeXMLDocument($doc);
|
||||
#
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// ParseXMLDocument
|
||||
#// Note that the caller must call DisposeXMLDocument on the returned doc
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub ParseXMLDocument($)
|
||||
{
|
||||
my($doc_path) = @_;
|
||||
|
||||
my $parser = new XML::DOM::Parser(ErrorContext => 2);
|
||||
my $doc = $parser->parsefile($doc_path);
|
||||
|
||||
return $doc;
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// DisposeXMLDocument
|
||||
#// Needed to avoid memory leaks - cleanup circular references for garbage collection
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub DisposeXMLDocument($)
|
||||
{
|
||||
my($doc) = @_;
|
||||
|
||||
$doc->dispose();
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// WriteXMLDocument
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub _pro5_tag_compression($$)
|
||||
{
|
||||
return 1; # Pro 5 is broken and can't import XML with <foo/> style tags
|
||||
}
|
||||
|
||||
sub _pro6plus_tag_compression($$)
|
||||
{
|
||||
return 0; # Pro 6 can deal with empty XML tags like <foo/>
|
||||
}
|
||||
|
||||
sub WriteXMLDocument($$$)
|
||||
{
|
||||
my($doc, $file_path, $ide_version) = @_;
|
||||
|
||||
if ($ide_version eq "4.0")
|
||||
{
|
||||
XML::DOM::setTagCompression(\&_pro5_tag_compression);
|
||||
}
|
||||
else
|
||||
{
|
||||
XML::DOM::setTagCompression(\&_pro6plus_tag_compression);
|
||||
}
|
||||
|
||||
$doc->printToFile($file_path);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// CleanupPro5XML
|
||||
#// XML Projects exported by Pro 5 contain garbage data under the MWMerge_MacOS_skipResources
|
||||
#// setting. This routine cleans this up, saving the result to a new file
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub CleanupPro5XML($$)
|
||||
{
|
||||
my($xml_path, $out_path) = @_;
|
||||
|
||||
local(*XML_FILE);
|
||||
open(XML_FILE, "< $xml_path") || die "Error: failed to open file $xml_path\n";
|
||||
|
||||
local(*CLEANED_FILE);
|
||||
open(CLEANED_FILE, "> $out_path") || die "Error: failed to open file $out_path for writing\n";
|
||||
|
||||
my $in_skip_resources_settings = 0;
|
||||
|
||||
while(<XML_FILE>)
|
||||
{
|
||||
my($line) = $_;
|
||||
|
||||
if ($line =~ /^<\?codewarrior/) # is processing inst line
|
||||
{
|
||||
my $test_line = $line;
|
||||
chomp($test_line);
|
||||
|
||||
my $out_line = $test_line;
|
||||
if ($test_line =~ /^<\?codewarrior\s+exportversion=\"(.+)\"\s+ideversion=\"(.+)\"\s*\?>$/)
|
||||
{
|
||||
my $export_version = $1;
|
||||
my $ide_version = $2;
|
||||
|
||||
$ide_version = "4.0_mozilla"; # pseudo IDE version so we know we touched it
|
||||
$out_line = "<?codewarrior exportversion=\"".$export_version."\" ideversion=\"".$ide_version."\"?>";
|
||||
}
|
||||
|
||||
print CLEANED_FILE "$out_line\n";
|
||||
next;
|
||||
}
|
||||
|
||||
if ($line =~ /MWMerge_MacOS_skipResources/)
|
||||
{
|
||||
$in_skip_resources_settings = 1;
|
||||
print CLEANED_FILE "$line";
|
||||
}
|
||||
elsif($in_skip_resources_settings && $line =~ /<!-- Settings for/)
|
||||
{
|
||||
# leaving bad settings lines. Write closing tag
|
||||
print CLEANED_FILE " <!-- Corrupted setting entries removed by script -->\n";
|
||||
print CLEANED_FILE " </SETTING>\n\n";
|
||||
|
||||
print CLEANED_FILE "$line";
|
||||
|
||||
$in_skip_resources_settings = 0;
|
||||
}
|
||||
elsif (!$in_skip_resources_settings)
|
||||
{
|
||||
print CLEANED_FILE "$line";
|
||||
}
|
||||
}
|
||||
|
||||
close(XML_FILE);
|
||||
close(CLEANED_FILE);
|
||||
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# SniffProjectXMLIDEVersion
|
||||
#
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
sub SniffProjectXMLIDEVersion($)
|
||||
{
|
||||
my($xml_path) = @_;
|
||||
|
||||
my $found_version = "";
|
||||
|
||||
local(*XML_FILE);
|
||||
open(XML_FILE, "< $xml_path") || die "Error: failed to open file $xml_path\n";
|
||||
|
||||
while(<XML_FILE>)
|
||||
{
|
||||
my($line) = $_;
|
||||
chomp($line);
|
||||
|
||||
if ($line =~ /^<\?codewarrior/) # is processing inst line
|
||||
{
|
||||
unless ($line =~ /^<\?codewarrior\s+exportversion=\"(.+)\"\s+ideversion=\"(.+)\"\s*\?>$/)
|
||||
{
|
||||
die "Error: Failed to find ideversion in $xml_path in line $line\n";
|
||||
}
|
||||
|
||||
my $export_version = $1;
|
||||
my $ide_version = $2;
|
||||
|
||||
$found_version = $ide_version;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
close(XML_FILE);
|
||||
|
||||
return $found_version;
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GetTargetsList
|
||||
#// Returns an array of target names
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub GetTargetsList($)
|
||||
{
|
||||
my($doc) = @_;
|
||||
|
||||
my $nodes = $doc->getElementsByTagName("TARGET");
|
||||
my $n = $nodes->getLength;
|
||||
|
||||
my @target_names;
|
||||
|
||||
for (my $i = 0; $i < $n; $i++)
|
||||
{
|
||||
my ($node) = $nodes->item($i);
|
||||
|
||||
my($target_name) = getChildElementTextContents($node, "NAME");
|
||||
push(@target_names, $target_name);
|
||||
}
|
||||
|
||||
return @target_names;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// CloneTarget
|
||||
#// Clone the named target, renaming it to 'new_name'
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub CloneTarget($$$)
|
||||
{
|
||||
my($doc, $target_name, $new_name) = @_;
|
||||
|
||||
my $target_node = getTargetNode($doc, $target_name);
|
||||
|
||||
# clone here
|
||||
my $target_clone = $target_node->cloneNode(1); # deep clone
|
||||
|
||||
# -- munge target settings --
|
||||
|
||||
# set the target name field
|
||||
setChildElementTextContents($doc, $target_clone, "NAME", $new_name);
|
||||
|
||||
# set the targetname pref
|
||||
setTargetNodeSetting($doc, $target_clone, "Targetname", $new_name);
|
||||
|
||||
# -- insert new target subtree --
|
||||
|
||||
my $target_list = $target_node->getParentNode();
|
||||
$target_list->appendChild($target_clone);
|
||||
|
||||
# -- now add to targetorder --
|
||||
my (@target_order_nodes) = getChildOfDocument($doc, "TARGETORDER");
|
||||
|
||||
my $target_order = @target_order_nodes[0];
|
||||
|
||||
my $new_order = $doc->createElement("ORDEREDTARGET");
|
||||
my $order_name = $doc->createElement("NAME");
|
||||
|
||||
$new_order->appendChild($order_name);
|
||||
|
||||
setChildElementTextContents($doc, $new_order, "NAME", $new_name);
|
||||
$target_order->appendChild($new_order);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// SetAsSharedLibraryTarget
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub SetAsSharedLibraryTarget($$$)
|
||||
{
|
||||
my($doc, $target_name, $output_name) = @_;
|
||||
|
||||
my $target_node = getTargetNode($doc, $target_name);
|
||||
|
||||
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_type", "SharedLibrary");
|
||||
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_filetype", "1936223330"); #'shlb'
|
||||
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_outfile", $output_name);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// AddFileToTarget
|
||||
#//
|
||||
#// Add a file to the specified target(s).
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub AddFileToTarget($$$)
|
||||
{
|
||||
my($doc, $target_list, $file_name) = @_;
|
||||
|
||||
# the file must be added in 3 places:
|
||||
# 1. in <TARGET><FILELIST><FILE> (with linkage flags if necessary)
|
||||
# 2. in <TARGET><LINKORDER><FILEREF>
|
||||
# 3. in <GROUPLIST><GROUP><FILEREF>
|
||||
die "Write me\n";
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// RemoveFileFromTarget
|
||||
#//
|
||||
#// Remove a file from the specified target, removing it from the entire project
|
||||
#// if no other targets reference it.
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub RemoveFileFromTarget($$$)
|
||||
{
|
||||
my($doc, $target_node, $file_name) = @_;
|
||||
|
||||
# the file must be removed in 3 places:
|
||||
# 1. in <TARGET><FILELIST><FILE>
|
||||
# 2. in <TARGET><LINKORDER><FILEREF>
|
||||
# 3. in <GROUPLIST><GROUP><FILEREF>
|
||||
|
||||
# first, remove from <FILELIST>
|
||||
my $filelist_node = getFirstChildElement($target_node, "FILELIST");
|
||||
unless ($filelist_node) { die "Error: failed to find FILELIST node\n"; }
|
||||
|
||||
my $file_node = getChildNodeByGrandchildContents($doc, $filelist_node, "FILE", "PATH", $file_name);
|
||||
unless ($file_node) { return; }
|
||||
|
||||
$filelist_node->removeChild($file_node);
|
||||
|
||||
# next, remove from <LINKORDER>
|
||||
my $linkorder_node = getFirstChildElement($target_node, "LINKORDER");
|
||||
unless ($linkorder_node) { die "Error: failed to find LINKORDER node\n"; }
|
||||
|
||||
my $fileref_node = getChildNodeByGrandchildContents($doc, $linkorder_node, "FILEREF", "PATH", $file_name);
|
||||
unless ($fileref_node) { die "Error: link order node for file $file_name not found\n"; }
|
||||
|
||||
$linkorder_node->removeChild($fileref_node);
|
||||
|
||||
# last, remove from <GROUPLIST>
|
||||
# <GROUPLIST> is cross-target, so we have to be careful here.
|
||||
my $grouplist_node = getChildOfDocument($doc, "GROUPLIST");
|
||||
unless ($grouplist_node) { die "Error: failed to find GROUPLIST node\n"; }
|
||||
|
||||
# if the file isn't in any other targets, remove it from the groups
|
||||
if (!GetFileInUse($doc, $file_name))
|
||||
{
|
||||
print "File $file_name is in no other targest. Removing from project\n";
|
||||
|
||||
my @group_nodes;
|
||||
getChildElementsOfType($doc, $grouplist_node, "GROUP", \@group_nodes);
|
||||
my $group_node;
|
||||
foreach $group_node (@group_nodes)
|
||||
{
|
||||
my @fileref_nodes;
|
||||
getChildElementsOfType($doc, $group_node, "FILEREF", \@fileref_nodes);
|
||||
|
||||
my $fileref_node;
|
||||
foreach $fileref_node (@fileref_nodes)
|
||||
{
|
||||
my $path_name = getChildElementTextContents($fileref_node, "PATH");
|
||||
if ($path_name eq $file_name)
|
||||
{
|
||||
print "Removing $file_name from project group list\n";
|
||||
$group_node->removeChild($fileref_node);
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
# can a file appear in more than one group?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// SetAsStaticLibraryTarget
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub SetAsStaticLibraryTarget($$$)
|
||||
{
|
||||
my($doc, $target_name, $output_name) = @_;
|
||||
|
||||
my $target_node = getTargetNode($doc, $target_name);
|
||||
|
||||
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_type", "Library");
|
||||
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_filetype", "1061109567"); #'????'
|
||||
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_outfile", $output_name);
|
||||
|
||||
# static targets don't need any library linkage, so we can remove linkage
|
||||
# with all .shlb and .Lib files.
|
||||
|
||||
my(@obsolete_files) = ("NSStdLibStubs", "InterfacesStubs", "InterfaceLib", "InternetConfigLib");
|
||||
|
||||
print " Removing libraries etc. from target\n";
|
||||
|
||||
# get all files in target
|
||||
my @target_files = GetTargetFilesList($doc, $target_name);
|
||||
my $target_file;
|
||||
foreach $target_file (@target_files)
|
||||
{
|
||||
if ($target_file =~ /(\.shlb|\.lib|\.Lib|\.o|\.exp)$/)
|
||||
{
|
||||
RemoveFileFromTarget($doc, $target_node, $target_file);
|
||||
}
|
||||
}
|
||||
|
||||
print " Removing stub libraries from target\n";
|
||||
|
||||
# then remove files with known names
|
||||
my $obs_file;
|
||||
foreach $obs_file (@obsolete_files)
|
||||
{
|
||||
RemoveFileFromTarget($doc, $target_node, $obs_file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// AddTarget
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub AddTarget($$)
|
||||
{
|
||||
my($doc, $target_name) = @_;
|
||||
|
||||
die "Write me\n";
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// RemoveTarget
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub RemoveTarget($$)
|
||||
{
|
||||
my($doc, $target_name) = @_;
|
||||
|
||||
die "Write me\n";
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GetTargetSetting
|
||||
#// Get the value for the specified setting in the specified target
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub GetTargetSetting($$$)
|
||||
{
|
||||
my($doc, $target_name, $setting_name) = @_;
|
||||
|
||||
my $target_node = getTargetNode($doc, $target_name);
|
||||
return getTargetNodeSetting($target_node, "VALUE");
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// SetTargetSetting
|
||||
#// Set the value for the specified setting in the specified target
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub SetTargetSetting($$$$)
|
||||
{
|
||||
my($doc, $target_name, $setting_name, $new_value) = @_;
|
||||
|
||||
my $target_node = getTargetNode($doc, $target_name);
|
||||
setTargetNodeSetting($doc, $target_node, "VALUE", $new_value);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GetTargetFilesList
|
||||
#// Return an array of the files in the target (in filelist order)
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub GetTargetFilesList($$)
|
||||
{
|
||||
my($doc, $target_name) = @_;
|
||||
|
||||
my $target_node = getTargetNode($doc, $target_name);
|
||||
|
||||
my @files_list;
|
||||
|
||||
my $filelist_node = getFirstChildElement($target_node, "FILELIST");
|
||||
unless ($filelist_node) { die "Error: failed to find FILELIST node\n"; }
|
||||
|
||||
my @file_nodes;
|
||||
getChildElementsOfType($doc, $filelist_node, "FILE", \@file_nodes);
|
||||
|
||||
my $node;
|
||||
foreach $node (@file_nodes)
|
||||
{
|
||||
my $file_name = getChildElementTextContents($node, "PATH");
|
||||
push(@files_list, $file_name);
|
||||
}
|
||||
|
||||
return @files_list;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// FileIsInTarget
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub FileIsInTarget($$$)
|
||||
{
|
||||
my($doc, $file_name, $target_name) = @_;
|
||||
|
||||
my $target_node = getTargetNode($doc, $target_name);
|
||||
unless ($target_node) { die "Error: no target found called $target_name\n"; }
|
||||
|
||||
my $file_node = GetTargetFileNode($doc, $target_node, $file_name);
|
||||
if ($file_node) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GetFileTargetsList
|
||||
#// Return an array of the targets that a file is in (expensive)
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub GetFileTargetsList($$)
|
||||
{
|
||||
my ($doc, $file_name) = @_;
|
||||
|
||||
my @target_list;
|
||||
|
||||
my @targets = GetTargetsList($doc);
|
||||
my $target;
|
||||
|
||||
foreach $target (@targets)
|
||||
{
|
||||
if (FileIsInTarget($doc, $file_name, $target))
|
||||
{
|
||||
push(@target_list, $target);
|
||||
}
|
||||
}
|
||||
|
||||
return @target_list;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GetTargetFileNode
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub GetTargetFileNode($$$)
|
||||
{
|
||||
my($doc, $target_node, $file_name) = @_;
|
||||
|
||||
my $filelist_node = getFirstChildElement($target_node, "FILELIST");
|
||||
unless ($filelist_node) { die "Error: failed to find FILELIST node\n"; }
|
||||
|
||||
my $file_node = getChildNodeByGrandchildContents($doc, $filelist_node, "FILE", "PATH", $file_name);
|
||||
|
||||
return $file_node;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GetFileInUse
|
||||
#// Return true if the file is used by any target
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub GetFileInUse($$)
|
||||
{
|
||||
my($doc, $file_name) = @_;
|
||||
|
||||
my $targetlist_node = getChildOfDocument($doc, "TARGETLIST");
|
||||
|
||||
my $target_node = $targetlist_node->getFirstChild();
|
||||
|
||||
while ($target_node)
|
||||
{
|
||||
if ($target_node->getNodeTypeName eq "ELEMENT_NODE" &&
|
||||
$target_node->getTagName() eq "TARGET")
|
||||
{
|
||||
# if this is a target node
|
||||
my $file_node = GetTargetFileNode($doc, $target_node, $file_name);
|
||||
if ($file_node) {
|
||||
return 1; # found it
|
||||
}
|
||||
}
|
||||
|
||||
$target_node = $target_node->getNextSibling();
|
||||
}
|
||||
|
||||
# not found
|
||||
return 0;
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getChildOfDocument
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getChildOfDocument($$)
|
||||
{
|
||||
my($doc, $child_type) = @_;
|
||||
|
||||
return getFirstChildElement($doc->getDocumentElement(), $child_type);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getFirstChildElement
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getFirstChildElement($$)
|
||||
{
|
||||
my($node, $element_name) = @_;
|
||||
|
||||
my $found_node;
|
||||
|
||||
unless ($node) { die "getFirstChildElement called with empty node\n"; }
|
||||
|
||||
#look for the first "element_name" child
|
||||
|
||||
my $child_node = $node->getFirstChild();
|
||||
|
||||
while ($child_node)
|
||||
{
|
||||
if ($child_node->getNodeTypeName eq "ELEMENT_NODE" &&
|
||||
$child_node->getTagName() eq $element_name)
|
||||
{
|
||||
$found_node = $child_node;
|
||||
last;
|
||||
}
|
||||
|
||||
$child_node = $child_node->getNextSibling();
|
||||
}
|
||||
|
||||
return $found_node;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getChildElementsOfType
|
||||
#//
|
||||
#// Return an array of refs to child nodes of the given type
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getChildElementsOfType($$$$)
|
||||
{
|
||||
my($doc, $node, $child_type, $array_ref) = @_;
|
||||
|
||||
my $child_node = $node->getFirstChild();
|
||||
|
||||
while ($child_node)
|
||||
{
|
||||
if ($child_node->getNodeTypeName eq "ELEMENT_NODE" &&
|
||||
$child_node->getTagName() eq $child_type)
|
||||
{
|
||||
push(@$array_ref, $child_node);
|
||||
}
|
||||
|
||||
$child_node = $child_node->getNextSibling();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getChildElementTextContents
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Given <FOOPY><NERD>Hi!</NERD></FOOPY>, where $node is <FOOPY>,
|
||||
# returns "Hi!". If > 1 <NERD> node, returns the contents of the first.
|
||||
#
|
||||
sub getChildElementTextContents($$)
|
||||
{
|
||||
my($node, $tag_name) = @_;
|
||||
|
||||
my $first_element = getFirstChildElement($node, $tag_name);
|
||||
my $text_node = $first_element->getFirstChild();
|
||||
|
||||
my $text_contents = "";
|
||||
|
||||
# concat adjacent text nodes
|
||||
while ($text_node)
|
||||
{
|
||||
if ($text_node->getNodeTypeName() ne "TEXT_NODE")
|
||||
{
|
||||
last;
|
||||
}
|
||||
|
||||
$text_contents = $text_contents.$text_node->getData();
|
||||
$text_node = $text_node->getNextSibling();
|
||||
}
|
||||
|
||||
return $text_contents;
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// setChildElementTextContents
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub setChildElementTextContents($$$$)
|
||||
{
|
||||
my($doc, $node, $tag_name, $contents_text) = @_;
|
||||
|
||||
my $first_element = getFirstChildElement($node, $tag_name);
|
||||
my $new_text_node = $doc->createTextNode($contents_text);
|
||||
|
||||
# replace all child elements with a text element
|
||||
removeAllChildren($first_element);
|
||||
|
||||
$first_element->appendChild($new_text_node);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getChildNodeByContents
|
||||
#//
|
||||
#// Consider <foo><bar><baz>Foopy</baz></bar><bar><baz>Loopy</baz></bar></foo>
|
||||
#// This function, when called with getChildNodeByContents($foonode, "bar", "baz", "Loopy")
|
||||
#// returns the second <bar> node.
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getChildNodeByGrandchildContents($$$$$)
|
||||
{
|
||||
my($doc, $node, $child_type, $gc_type, $gc_contents) = @_; # gc = grandchild
|
||||
|
||||
my $found_node;
|
||||
my $child_node = $node->getFirstChild();
|
||||
while ($child_node)
|
||||
{
|
||||
if ($child_node->getNodeTypeName eq "ELEMENT_NODE" &&
|
||||
$child_node->getTagName() eq $child_type)
|
||||
{
|
||||
# check for a child of this node of type
|
||||
my $child_contents = getChildElementTextContents($child_node, $gc_type);
|
||||
|
||||
if ($child_contents eq $gc_contents)
|
||||
{
|
||||
$found_node = $child_node;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
$child_node = $child_node->getNextSibling();
|
||||
}
|
||||
|
||||
return $found_node;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getTargetNode
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getTargetNode($$)
|
||||
{
|
||||
my($doc, $target_name) = @_;
|
||||
|
||||
my $targetlist_node = getChildOfDocument($doc, "TARGETLIST");
|
||||
return getChildNodeByGrandchildContents($doc, $targetlist_node, "TARGET", "NAME", $target_name);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getTargetNamedSettingNode
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getTargetNamedSettingNode($$)
|
||||
{
|
||||
my($target_node, $setting_name) = @_;
|
||||
|
||||
my $setting_node;
|
||||
|
||||
my $settinglist_node = getFirstChildElement($target_node, "SETTINGLIST");
|
||||
my $child_node = $settinglist_node->getFirstChild();
|
||||
|
||||
while ($child_node)
|
||||
{
|
||||
if ($child_node->getNodeTypeName ne "ELEMENT_NODE")
|
||||
{
|
||||
$child_node = $child_node->getNextSibling();
|
||||
next;
|
||||
}
|
||||
|
||||
if ($child_node->getTagName() eq "SETTING")
|
||||
{
|
||||
my $set_name = getChildElementTextContents($child_node, "NAME");
|
||||
|
||||
if ($set_name eq $setting_name)
|
||||
{
|
||||
$setting_node = $child_node;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
$child_node = $child_node->getNextSibling();
|
||||
}
|
||||
|
||||
return $setting_node;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getTargetNodeSetting
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getTargetNodeSetting($$)
|
||||
{
|
||||
my($target_node, $setting_name) = @_;
|
||||
|
||||
my $setting_node = getTargetNamedSettingNode($target_node, $setting_name);
|
||||
return getChildElementTextContents($setting_node, "VALUE");
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// setTargetNodeSetting
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub setTargetNodeSetting($$$$)
|
||||
{
|
||||
my($doc, $target_node, $setting_name, $new_value) = @_;
|
||||
|
||||
my $setting_node = getTargetNamedSettingNode($target_node, $setting_name);
|
||||
|
||||
setChildElementTextContents($doc, $setting_node, "VALUE", $new_value);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// elementInArray
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub elementInArray($$)
|
||||
{
|
||||
my($element, $array) = @_;
|
||||
my $test;
|
||||
foreach $test (@$array)
|
||||
{
|
||||
if ($test eq $element) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// removeAllChildren
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub removeAllChildren($)
|
||||
{
|
||||
my($node) = @_;
|
||||
|
||||
my $child_node = $node->getFirstChild();
|
||||
|
||||
while ($child_node)
|
||||
{
|
||||
$node->removeChild($child_node);
|
||||
$child_node = $node->getFirstChild();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// dumpNodeData
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub dumpNodeData($)
|
||||
{
|
||||
my($node) = @_;
|
||||
|
||||
unless ($node) { die "Null node passed to dumpNodeData\n"; }
|
||||
|
||||
print "Dumping node $node\n";
|
||||
|
||||
my($node_type) = $node->getNodeTypeName();
|
||||
|
||||
if ($node_type eq "ELEMENT_NODE")
|
||||
{
|
||||
my($node_name) = $node->getTagName();
|
||||
print "Element $node_name\n";
|
||||
}
|
||||
elsif ($node_type eq "TEXT_NODE")
|
||||
{
|
||||
my($node_data) = $node->getData;
|
||||
# my(@node_vals) = unpack("C*", $node_data);
|
||||
print "Text '$node_data'\n"; # may contain LF chars
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Node $node_type\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// dumpNodeTree
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub dumpNodeTree($)
|
||||
{
|
||||
my($node) = @_;
|
||||
|
||||
my($child_node) = $node->getFirstChild();
|
||||
|
||||
unless ($child_node) { return; }
|
||||
|
||||
# recurse
|
||||
dumpNodeData($child_node);
|
||||
|
||||
# then go through child nodes
|
||||
while ($child_node)
|
||||
{
|
||||
dumpNodeTree($child_node);
|
||||
|
||||
$child_node = $child_node->getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
#-------------------------------------------------------------------------------
|
||||
# These 3 lists are the 'master lists' to control what gets built.
|
||||
#
|
||||
# Ordering in these arrays is important; it has to reflect the order in
|
||||
# which the build occurs.
|
||||
#
|
||||
# Setting containing spaces must be quoted with double quotes.
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
build_flags
|
||||
all 1
|
||||
pull 0
|
||||
dist 0
|
||||
config 0
|
||||
xpidl 0
|
||||
idl 0
|
||||
stubs 0
|
||||
runtime 0
|
||||
common 0
|
||||
imglib 0
|
||||
libimg2 0
|
||||
necko 0
|
||||
security 0
|
||||
browserutils 0
|
||||
intl 0
|
||||
nglayout 0
|
||||
accessiblity 0
|
||||
editor 0
|
||||
embedding 0
|
||||
viewer 0
|
||||
xpapp 0
|
||||
extensions 0
|
||||
plugins 0
|
||||
mailnews 0
|
||||
apprunner 0
|
||||
resources 0
|
||||
|
||||
options_flags
|
||||
pull_by_date 0
|
||||
chrome_jars 1
|
||||
chrome_files 0
|
||||
use_jars 1
|
||||
transformiix 1
|
||||
mathml 0 MOZ_MATHML
|
||||
svg 0 MOZ_SVG
|
||||
# svg requires libart, which is an lgpl library. You need to pull it
|
||||
# explicitly.
|
||||
libart_lgpl 0
|
||||
mng 1
|
||||
ldap 1 MOZ_LDAP_XPCOM
|
||||
ldap_experimental 0 MOZ_LDAP_XPCOM_EXPERIMENTAL
|
||||
xmlextras 1
|
||||
wsp 0 MOZ_WSP
|
||||
inspector 1
|
||||
mailextras 1
|
||||
xptlink 0
|
||||
psm 0 MOZ_PSM
|
||||
embedding_test 1
|
||||
embedding_chrome 0
|
||||
embedding_xulprefs 0
|
||||
embedding_xulsecurity 0
|
||||
carbon 0 TARGET_CARBON
|
||||
useimg2 1 USE_IMG2
|
||||
lowmem 0 MOZ_MAC_LOWMEM
|
||||
accessible 1 ACCESSIBILITY
|
||||
bidi 1 IBMBIDI
|
||||
p3p 0
|
||||
jsd 1
|
||||
venkman 1
|
||||
moz_logging 1 MOZ_LOGGING
|
||||
chatzilla 1
|
||||
content_packs 1
|
||||
xml_rpc 1
|
||||
cview 1
|
||||
help 1
|
||||
timeline 0 MOZ_TIMELINE
|
||||
static_build 0 MOZ_STATIC_COMPONENT_LIBS
|
||||
string_debug 0 DEBUG_STRING
|
||||
string_stats 0 DEBUG_STRING_STATS
|
||||
xpctools 0 XPC_TOOLS_SUPPORT
|
||||
smime 1
|
||||
mdn 1
|
||||
print_preview 1 NS_PRINT_PREVIEW
|
||||
moz_xul 1 MOZ_XUL
|
||||
|
||||
filepath_flags
|
||||
idepath ":CodeWarrior IDE Path.txt"
|
||||
sessionpath ":Mozilla session path.txt"
|
||||
buildlogfilepath ":Build Logs:Mozilla build log.txt" # this is a path
|
||||
scriptlogfilepath ":Build Logs:Mozilla script log.txt"
|
||||
@@ -1,22 +0,0 @@
|
||||
# List of modules to check out. Format is
|
||||
# module, (tag), (date)
|
||||
# where tag and date are optional (non-trailing commas are required)
|
||||
#
|
||||
# Examples:
|
||||
# mozilla/nsprpub, NSPRPUB_CLIENT_TAG
|
||||
# mozilla/gc, , 10/25/2000 12:00:00
|
||||
#
|
||||
|
||||
mozilla/nsprpub, NETSCAPE_7_02_RELEASE
|
||||
mozilla/security/nss, NETSCAPE_7_02_RELEASE
|
||||
mozilla/security/manager, NETSCAPE_7_02_RELEASE
|
||||
mozilla/accessible, NETSCAPE_7_02_RELEASE
|
||||
mozilla/directory/c-sdk, NETSCAPE_7_02_RELEASE
|
||||
mozilla/lib/mac/Instrumentation, NETSCAPE_7_02_RELEASE
|
||||
mozilla/gfx2, NETSCAPE_7_02_RELEASE
|
||||
mozilla/modules/libpr0n, NETSCAPE_7_02_RELEASE
|
||||
SeaMonkeyAll, NETSCAPE_7_02_RELEASE
|
||||
|
||||
## You need this if you want to be able to use SVG
|
||||
## Note that this library is under the LGPL, not the MPL
|
||||
#mozilla/other-licenses/libart_lgpl
|
||||
@@ -1,79 +0,0 @@
|
||||
#!perl
|
||||
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 mozilla.org code.
|
||||
#
|
||||
# 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):
|
||||
# Simon Fraser <sfraser@netscape.com>
|
||||
#
|
||||
|
||||
require 5.004;
|
||||
|
||||
use strict;
|
||||
|
||||
use Cwd;
|
||||
use Moz::BuildUtils;
|
||||
use Moz::BuildCore;
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# Where have the build options gone?
|
||||
#
|
||||
# The various build flags have been centralized into one place.
|
||||
# The master list of options is in MozBuildFlags.txt. However,
|
||||
# you should never need to edit that file, or this one.
|
||||
#
|
||||
# To customize what gets built, or where to start the build,
|
||||
# edit the $prefs_file_name file in
|
||||
# System Folder:Preferences:Mozilla build prefs:
|
||||
# Documentation is provided in that file.
|
||||
#-------------------------------------------------------------
|
||||
|
||||
my($prefs_file_name) = "Mozilla pull prefs";
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# hashes to hold build options
|
||||
#-------------------------------------------------------------
|
||||
my(%build);
|
||||
my(%options);
|
||||
my(%filepaths);
|
||||
my(%optiondefines);
|
||||
|
||||
# Hash of input files for this build. Eventually, there will be
|
||||
# input files for manifests, and projects too.
|
||||
my(%inputfiles) = (
|
||||
"buildflags", "MozillaBuildFlags.txt",
|
||||
"checkoutdata", "MozillaCheckoutList.txt",
|
||||
"buildprogress", "",
|
||||
"buildmodule", "MozillaBuildList.pm",
|
||||
"checkouttime", "Mozilla last checkout"
|
||||
);
|
||||
#-------------------------------------------------------------
|
||||
# end build hashes
|
||||
#-------------------------------------------------------------
|
||||
|
||||
# set the build root directory, which is the the dir above mozilla
|
||||
SetupBuildRootDir(":mozilla:build:mac:build_scripts");
|
||||
|
||||
# Set up all the flags on $main::, like DEBUG, CARBON etc.
|
||||
# Override the defaults using the preferences files.
|
||||
SetupDefaultBuildOptions(0, ":mozilla:dist:viewer:", "");
|
||||
|
||||
my($do_checkout) = 1;
|
||||
my($do_build) = 0;
|
||||
|
||||
RunBuild($do_checkout, $do_build, \%inputfiles, $prefs_file_name);
|
||||
@@ -1,4 +0,0 @@
|
||||
This directory is merely here to test the project editor server. It will go away after
|
||||
it is validated. For more information, see http://camelot.
|
||||
|
||||
Testing watchers.
|
||||
@@ -1 +0,0 @@
|
||||
// test1.cpp
|
||||
@@ -1 +0,0 @@
|
||||
// test2.cpp
|
||||
@@ -1 +0,0 @@
|
||||
// test2.cpp
|
||||
@@ -1,4 +0,0 @@
|
||||
// test2.cpp
|
||||
|
||||
as
|
||||
dfasdf
|
||||
@@ -1,12 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ConditionalMacros.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
FILE* file = fopen("BuildSystemInfo.pm", "w");
|
||||
if (file != NULL) {
|
||||
fprintf(file, "$UNIVERSAL_INTERFACES_VERSION=0x%04X;\n", UNIVERSAL_INTERFACES_VERSION);
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
@@ -1,650 +0,0 @@
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 mozilla.org code.
|
||||
#
|
||||
# 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): Stephen Lamm
|
||||
|
||||
# Build the Mozilla client.
|
||||
#
|
||||
# This needs CVSROOT set to work, e.g.,
|
||||
# setenv CVSROOT :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot
|
||||
# or
|
||||
# setenv CVSROOT :pserver:username%somedomain.org@cvs.mozilla.org:/cvsroot
|
||||
#
|
||||
# To checkout and build a tree,
|
||||
# 1. cvs co mozilla/client.mk
|
||||
# 2. cd mozilla
|
||||
# 3. gmake -f client.mk
|
||||
#
|
||||
# Other targets (gmake -f client.mk [targets...]),
|
||||
# checkout
|
||||
# build
|
||||
# clean (realclean is now the same as clean)
|
||||
# distclean
|
||||
#
|
||||
# See http://www.mozilla.org/build/unix.html for more information.
|
||||
#
|
||||
# Options:
|
||||
# MOZ_OBJDIR - Destination object directory
|
||||
# MOZ_CO_DATE - Date tag to use for checkout (default: none)
|
||||
# MOZ_CO_MODULE - Module to checkout (default: SeaMonkeyAll)
|
||||
# MOZ_CVS_FLAGS - Flags to pass cvs (default: -q -z3)
|
||||
# MOZ_CO_FLAGS - Flags to pass after 'cvs co' (default: -P)
|
||||
# MOZ_MAKE_FLAGS - Flags to pass to $(MAKE)
|
||||
# MOZ_CO_BRANCH - Branch tag (Deprecated. Use MOZ_CO_TAG below.)
|
||||
#
|
||||
|
||||
#######################################################################
|
||||
# Checkout Tags
|
||||
#
|
||||
# For branches, uncomment the MOZ_CO_TAG line with the proper tag,
|
||||
# and commit this file on that tag.
|
||||
MOZ_CO_TAG = NETSCAPE_7_02_RELEASE
|
||||
NSPR_CO_TAG = NETSCAPE_7_02_RELEASE
|
||||
PSM_CO_TAG = NETSCAPE_7_02_RELEASE
|
||||
NSS_CO_TAG = NETSCAPE_7_02_RELEASE
|
||||
LDAPCSDK_CO_TAG = NETSCAPE_7_02_RELEASE
|
||||
ACCESSIBLE_CO_TAG = NETSCAPE_7_02_RELEASE
|
||||
GFX2_CO_TAG = NETSCAPE_7_02_RELEASE
|
||||
IMGLIB2_CO_TAG = NETSCAPE_7_02_RELEASE
|
||||
BUILD_MODULES = all
|
||||
|
||||
#######################################################################
|
||||
# Defines
|
||||
#
|
||||
CVS = cvs
|
||||
|
||||
CWD := $(shell pwd)
|
||||
|
||||
ifeq "$(CWD)" "/"
|
||||
CWD := /.
|
||||
endif
|
||||
|
||||
ifneq (, $(wildcard client.mk))
|
||||
# Ran from mozilla directory
|
||||
ROOTDIR := $(shell dirname $(CWD))
|
||||
TOPSRCDIR := $(CWD)
|
||||
else
|
||||
# Ran from mozilla/.. directory (?)
|
||||
ROOTDIR := $(CWD)
|
||||
TOPSRCDIR := $(CWD)/mozilla
|
||||
endif
|
||||
|
||||
# on os2, TOPSRCDIR may have two forward slashes in a row, which doesn't
|
||||
# work; replace first instance with one forward slash
|
||||
TOPSRCDIR := $(shell echo "$(TOPSRCDIR)" | sed -e 's%//%/%')
|
||||
|
||||
ifndef TOPSRCDIR_MOZ
|
||||
TOPSRCDIR_MOZ=$(TOPSRCDIR)
|
||||
endif
|
||||
|
||||
# if ROOTDIR equals only drive letter (i.e. "C:"), set to "/"
|
||||
DIRNAME := $(shell echo "$(ROOTDIR)" | sed -e 's/^.://')
|
||||
ifeq ($(DIRNAME),)
|
||||
ROOTDIR := /.
|
||||
endif
|
||||
|
||||
AUTOCONF := autoconf
|
||||
MKDIR := mkdir
|
||||
SH := /bin/sh
|
||||
ifndef MAKE
|
||||
MAKE := gmake
|
||||
endif
|
||||
|
||||
CONFIG_GUESS_SCRIPT := $(wildcard $(TOPSRCDIR)/build/autoconf/config.guess)
|
||||
ifdef CONFIG_GUESS_SCRIPT
|
||||
CONFIG_GUESS = $(shell $(CONFIG_GUESS_SCRIPT))
|
||||
else
|
||||
_IS_FIRST_CHECKOUT := 1
|
||||
endif
|
||||
|
||||
####################################
|
||||
# CVS
|
||||
|
||||
# Add the CVS root to CVS_FLAGS if needed
|
||||
CVS_ROOT_IN_TREE := $(shell cat $(TOPSRCDIR)/CVS/Root 2>/dev/null)
|
||||
ifneq ($(CVS_ROOT_IN_TREE),)
|
||||
ifneq ($(CVS_ROOT_IN_TREE),$(CVSROOT))
|
||||
CVS_FLAGS := -d $(CVS_ROOT_IN_TREE)
|
||||
endif
|
||||
endif
|
||||
|
||||
CVSCO = $(strip $(CVS) $(CVS_FLAGS) co $(CVS_CO_FLAGS))
|
||||
CVSCO_LOGFILE := $(ROOTDIR)/cvsco.log
|
||||
CVSCO_LOGFILE := $(shell echo $(CVSCO_LOGFILE) | sed s%//%/%)
|
||||
|
||||
ifdef MOZ_CO_TAG
|
||||
CVS_CO_FLAGS := -r $(MOZ_CO_TAG)
|
||||
endif
|
||||
|
||||
####################################
|
||||
# Load mozconfig Options
|
||||
|
||||
# See build pages, http://www.mozilla.org/build/unix.html,
|
||||
# for how to set up mozconfig.
|
||||
MOZCONFIG_LOADER := mozilla/build/autoconf/mozconfig2client-mk
|
||||
MOZCONFIG_FINDER := mozilla/build/autoconf/mozconfig-find
|
||||
MOZCONFIG_MODULES := mozilla/build/unix/modules.mk
|
||||
run_for_side_effects := \
|
||||
$(shell cd $(ROOTDIR); \
|
||||
if test "$(_IS_FIRST_CHECKOUT)"; then \
|
||||
$(CVSCO) $(MOZCONFIG_FINDER) $(MOZCONFIG_LOADER) $(MOZCONFIG_MODULES); \
|
||||
else true; \
|
||||
fi; \
|
||||
$(MOZCONFIG_LOADER) $(TOPSRCDIR) mozilla/.mozconfig.mk > mozilla/.mozconfig.out)
|
||||
include $(TOPSRCDIR)/.mozconfig.mk
|
||||
include $(TOPSRCDIR)/build/unix/modules.mk
|
||||
|
||||
####################################
|
||||
# Options that may come from mozconfig
|
||||
|
||||
# Change CVS flags if anonymous root is requested
|
||||
ifdef MOZ_CO_USE_MIRROR
|
||||
CVS_FLAGS := -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot
|
||||
endif
|
||||
|
||||
# MOZ_CVS_FLAGS - Basic CVS flags
|
||||
ifeq "$(origin MOZ_CVS_FLAGS)" "undefined"
|
||||
CVS_FLAGS := $(CVS_FLAGS) -q -z 3
|
||||
else
|
||||
CVS_FLAGS := $(MOZ_CVS_FLAGS)
|
||||
endif
|
||||
|
||||
# This option is deprecated. The best way to have client.mk pull a tag
|
||||
# is to set MOZ_CO_TAG (see above) and commit that change on the tag.
|
||||
ifdef MOZ_CO_BRANCH
|
||||
$(warning Use MOZ_CO_TAG instead of MOZ_CO_BRANCH)
|
||||
CVS_CO_FLAGS := -r $(MOZ_CO_BRANCH)
|
||||
endif
|
||||
|
||||
# MOZ_CO_FLAGS - Anything that we should use on all checkouts
|
||||
ifeq "$(origin MOZ_CO_FLAGS)" "undefined"
|
||||
CVS_CO_FLAGS := $(CVS_CO_FLAGS) -P
|
||||
else
|
||||
CVS_CO_FLAGS := $(CVS_CO_FLAGS) $(MOZ_CO_FLAGS)
|
||||
endif
|
||||
|
||||
ifdef MOZ_CO_DATE
|
||||
CVS_CO_DATE_FLAGS := -D "$(MOZ_CO_DATE)"
|
||||
endif
|
||||
|
||||
ifdef MOZ_OBJDIR
|
||||
OBJDIR := $(MOZ_OBJDIR)
|
||||
MOZ_MAKE := $(MAKE) $(MOZ_MAKE_FLAGS) -C $(OBJDIR)
|
||||
else
|
||||
OBJDIR := $(TOPSRCDIR)
|
||||
MOZ_MAKE := $(MAKE) $(MOZ_MAKE_FLAGS)
|
||||
endif
|
||||
|
||||
####################################
|
||||
# CVS defines for PSM
|
||||
#
|
||||
PSM_CO_MODULE= mozilla/security/manager
|
||||
PSM_CO_FLAGS := -P -A
|
||||
ifdef MOZ_CO_FLAGS
|
||||
PSM_CO_FLAGS := $(MOZ_CO_FLAGS)
|
||||
endif
|
||||
ifdef PSM_CO_TAG
|
||||
PSM_CO_FLAGS := $(PSM_CO_FLAGS) -r $(PSM_CO_TAG)
|
||||
endif
|
||||
CVSCO_PSM = $(CVS) $(CVS_FLAGS) co $(PSM_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(PSM_CO_MODULE)
|
||||
|
||||
####################################
|
||||
# CVS defines for NSS
|
||||
#
|
||||
NSS_CO_MODULE = mozilla/security/nss \
|
||||
mozilla/security/coreconf \
|
||||
$(NULL)
|
||||
|
||||
NSS_CO_FLAGS := -P
|
||||
ifdef MOZ_CO_FLAGS
|
||||
NSS_CO_FLAGS := $(MOZ_CO_FLAGS)
|
||||
endif
|
||||
ifdef NSS_CO_TAG
|
||||
NSS_CO_FLAGS := $(NSS_CO_FLAGS) -r $(NSS_CO_TAG)
|
||||
endif
|
||||
# Cannot pull static tags by date
|
||||
ifeq ($(NSS_CO_TAG),NSS_CLIENT_TAG)
|
||||
CVSCO_NSS = $(CVS) $(CVS_FLAGS) co $(NSS_CO_FLAGS) $(NSS_CO_MODULE)
|
||||
else
|
||||
CVSCO_NSS = $(CVS) $(CVS_FLAGS) co $(NSS_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(NSS_CO_MODULE)
|
||||
endif
|
||||
|
||||
####################################
|
||||
# CVS defines for NSPR
|
||||
#
|
||||
NSPR_CO_MODULE = mozilla/nsprpub
|
||||
NSPR_CO_FLAGS := -P
|
||||
ifdef MOZ_CO_FLAGS
|
||||
NSPR_CO_FLAGS := $(MOZ_CO_FLAGS)
|
||||
endif
|
||||
ifdef NSPR_CO_TAG
|
||||
NSPR_CO_FLAGS := $(NSPR_CO_FLAGS) -r $(NSPR_CO_TAG)
|
||||
endif
|
||||
# Cannot pull static tags by date
|
||||
ifeq ($(NSPR_CO_TAG),NSPRPUB_CLIENT_TAG)
|
||||
CVSCO_NSPR = $(CVS) $(CVS_FLAGS) co $(NSPR_CO_FLAGS) $(NSPR_CO_MODULE)
|
||||
else
|
||||
CVSCO_NSPR = $(CVS) $(CVS_FLAGS) co $(NSPR_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(NSPR_CO_MODULE)
|
||||
endif
|
||||
|
||||
####################################
|
||||
# CVS defines for the C LDAP SDK
|
||||
#
|
||||
LDAPCSDK_CO_MODULE = mozilla/directory/c-sdk
|
||||
LDAPCSDK_CO_FLAGS := -P
|
||||
ifdef MOZ_CO_FLAGS
|
||||
LDAPCSDK_CO_FLAGS := $(MOZ_CO_FLAGS)
|
||||
endif
|
||||
ifdef LDAPCSDK_CO_TAG
|
||||
LDAPCSDK_CO_FLAGS := $(LDAPCSDK_CO_FLAGS) -r $(LDAPCSDK_CO_TAG)
|
||||
endif
|
||||
CVSCO_LDAPCSDK = $(CVS) $(CVS_FLAGS) co $(LDAPCSDK_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(LDAPCSDK_CO_MODULE)
|
||||
|
||||
####################################
|
||||
# CVS defines for the C LDAP SDK
|
||||
#
|
||||
ACCESSIBLE_CO_MODULE = mozilla/accessible
|
||||
ACCESSIBLE_CO_FLAGS := -P
|
||||
ifdef MOZ_CO_FLAGS
|
||||
ACCESSIBLE_CO_FLAGS := $(MOZ_CO_FLAGS)
|
||||
endif
|
||||
ifdef ACCESSIBLE_CO_TAG
|
||||
ACCESSIBLE_CO_FLAGS := $(ACCESSIBLE_CO_FLAGS) -r $(ACCESSIBLE_CO_TAG)
|
||||
endif
|
||||
CVSCO_ACCESSIBLE = $(CVS) $(CVS_FLAGS) co $(ACCESSIBLE_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(ACCESSIBLE_CO_MODULE)
|
||||
|
||||
####################################
|
||||
# CVS defines for gfx2
|
||||
#
|
||||
GFX2_CO_MODULE = mozilla/gfx2
|
||||
GFX2_CO_FLAGS := -P
|
||||
ifdef MOZ_CO_FLAGS
|
||||
GFX2_CO_FLAGS := $(MOZ_CO_FLAGS)
|
||||
endif
|
||||
ifdef GFX2_CO_TAG
|
||||
GFX2_CO_FLAGS := $(GFX2_CO_FLAGS) -r $(GFX2_CO_TAG)
|
||||
endif
|
||||
CVSCO_GFX2 = $(CVS) $(CVS_FLAGS) co $(GFX2_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(GFX2_CO_MODULE)
|
||||
|
||||
####################################
|
||||
# CVS defines for new image library
|
||||
#
|
||||
IMGLIB2_CO_MODULE = mozilla/modules/libpr0n
|
||||
IMGLIB2_CO_FLAGS := -P
|
||||
ifdef MOZ_CO_FLAGS
|
||||
IMGLIB2_CO_FLAGS := $(MOZ_CO_FLAGS)
|
||||
endif
|
||||
ifdef IMGLIB2_CO_TAG
|
||||
IMGLIB2_CO_FLAGS := $(IMGLIB2_CO_FLAGS) -r $(IMGLIB2_CO_TAG)
|
||||
endif
|
||||
CVSCO_IMGLIB2 = $(CVS) $(CVS_FLAGS) co $(IMGLIB2_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(IMGLIB2_CO_MODULE)
|
||||
|
||||
####################################
|
||||
# CVS defines for standalone modules
|
||||
#
|
||||
ifneq ($(BUILD_MODULES),all)
|
||||
MOZ_CO_MODULE := $(filter-out $(NSPRPUB_DIR) security directory/c-sdk, $(BUILD_MODULE_CVS))
|
||||
MOZ_CO_MODULE += allmakefiles.sh client.mk aclocal.m4 configure configure.in
|
||||
MOZ_CO_MODULE += Makefile.in
|
||||
MOZ_CO_MODULE := $(addprefix mozilla/, $(MOZ_CO_MODULE))
|
||||
|
||||
NOSUBDIRS_MODULE := $(addprefix mozilla/, $(BUILD_MODULE_CVS_NS))
|
||||
ifneq ($(NOSUBDIRS_MODULE),)
|
||||
CVSCO_NOSUBDIRS := $(CVSCO) -l $(CVS_CO_DATE_FLAGS) $(NOSUBDIRS_MODULE)
|
||||
endif
|
||||
|
||||
ifeq (,$(filter $(NSPRPUB_DIR), $(BUILD_MODULE_CVS)))
|
||||
CVSCO_NSPR :=
|
||||
endif
|
||||
ifeq (,$(filter security security/manager, $(BUILD_MODULE_CVS)))
|
||||
CVSCO_PSM :=
|
||||
CVSCO_NSS :=
|
||||
endif
|
||||
ifeq (,$(filter directory/c-sdk, $(BUILD_MODULE_CVS)))
|
||||
CVSCO_LDAPCSDK :=
|
||||
endif
|
||||
ifeq (,$(filter accessible, $(BUILD_MODULE_CVS)))
|
||||
CVSCO_ACCESSIBLE :=
|
||||
endif
|
||||
ifeq (,$(filter gfx2, $(BUILD_MODULE_CVS)))
|
||||
CVSCO_GFX2 :=
|
||||
endif
|
||||
ifeq (,$(filter modules/libpr0n, $(BUILD_MODULE_CVS)))
|
||||
CVSCO_IMGLIB2 :=
|
||||
endif
|
||||
endif
|
||||
|
||||
####################################
|
||||
# CVS defines for SeaMonkey
|
||||
#
|
||||
ifeq ($(MOZ_CO_MODULE),)
|
||||
MOZ_CO_MODULE := SeaMonkeyAll
|
||||
endif
|
||||
CVSCO_SEAMONKEY := $(CVSCO) $(CVS_CO_DATE_FLAGS) $(MOZ_CO_MODULE)
|
||||
|
||||
####################################
|
||||
# CVS defined for libart (pulled and built if MOZ_INTERNAL_LIBART_LGPL is set)
|
||||
#
|
||||
CVSCO_LIBART := $(CVSCO) $(CVS_CO_DATE_FLAGS) mozilla/other-licenses/libart_lgpl
|
||||
|
||||
ifdef MOZ_INTERNAL_LIBART_LGPL
|
||||
FASTUPDATE_LIBART := fast_update $(CVSCO_LIBART)
|
||||
CHECKOUT_LIBART := cvs_co $(CVSCO_LIBART)
|
||||
else
|
||||
CHECKOUT_LIBART := true
|
||||
FASTUPDATE_LIBART := true
|
||||
endif
|
||||
|
||||
####################################
|
||||
# CVS defines for Calendar (pulled and built if MOZ_CALENDAR is set)
|
||||
#
|
||||
CVSCO_CALENDAR := $(CVSCO) $(CVS_CO_DATE_FLAGS) mozilla/calendar
|
||||
|
||||
ifdef MOZ_CALENDAR
|
||||
FASTUPDATE_CALENDAR := fast_update $(CVSCO_CALENDAR)
|
||||
CHECKOUT_CALENDAR := cvs_co $(CVSCO_CALENDAR)
|
||||
else
|
||||
CHECKOUT_CALENDAR := true
|
||||
FASTUPDATE_CALENDAR := true
|
||||
endif
|
||||
|
||||
|
||||
# because some cygwin tools can't handle native dos-drive paths & vice-versa
|
||||
# force configure to use a relative path for --srcdir
|
||||
# need a better check for win32
|
||||
# and we need to get OBJDIR earlier
|
||||
ifdef MOZ_TOOLS
|
||||
_tmpobjdir := $(shell cygpath -u $(OBJDIR))
|
||||
_abs2rel := $(shell cygpath -w $(TOPSRCDIR)/build/unix/abs2rel.pl | sed -e 's|\\|/|g')
|
||||
_OBJ2SRCPATH := $(shell $(_abs2rel) $(TOPSRCDIR) $(_tmpobjdir))
|
||||
endif
|
||||
|
||||
#######################################################################
|
||||
# Rules
|
||||
#
|
||||
|
||||
# Print out any options loaded from mozconfig.
|
||||
all build checkout clean depend distclean export libs install realclean::
|
||||
@if test -f .mozconfig.out; then \
|
||||
cat .mozconfig.out; \
|
||||
rm -f .mozconfig.out; \
|
||||
else true; \
|
||||
fi
|
||||
|
||||
ifdef _IS_FIRST_CHECKOUT
|
||||
all:: checkout build
|
||||
else
|
||||
all:: checkout alldep
|
||||
endif
|
||||
|
||||
# Windows equivalents
|
||||
pull_all: checkout
|
||||
build_all: build
|
||||
build_all_dep: alldep
|
||||
build_all_depend: alldep
|
||||
clobber clobber_all: clean
|
||||
pull_and_build_all: checkout alldep
|
||||
|
||||
# Do everything from scratch
|
||||
everything: checkout clean build
|
||||
|
||||
####################################
|
||||
# CVS checkout
|
||||
#
|
||||
checkout::
|
||||
# @: Backup the last checkout log.
|
||||
@if test -f $(CVSCO_LOGFILE) ; then \
|
||||
mv $(CVSCO_LOGFILE) $(CVSCO_LOGFILE).old; \
|
||||
else true; \
|
||||
fi
|
||||
ifdef RUN_AUTOCONF_LOCALLY
|
||||
@echo "Removing local configures" ; \
|
||||
cd $(ROOTDIR) && \
|
||||
$(RM) -f mozilla/configure mozilla/nsprpub/configure \
|
||||
mozilla/directory/c-sdk/configure
|
||||
endif
|
||||
@echo "checkout start: "`date` | tee $(CVSCO_LOGFILE)
|
||||
@echo '$(CVSCO) mozilla/client.mk mozilla/build/unix/modules.mk'; \
|
||||
cd $(ROOTDIR) && \
|
||||
$(CVSCO) mozilla/client.mk mozilla/build/unix/modules.mk
|
||||
@cd $(ROOTDIR) && $(MAKE) -f mozilla/client.mk real_checkout
|
||||
|
||||
real_checkout:
|
||||
# @: Start the checkout. Split the output to the tty and a log file. \
|
||||
# : If it fails, touch an error file because "tee" hides the error.
|
||||
@failed=.cvs-failed.tmp; rm -f $$failed*; \
|
||||
cvs_co() { echo "$$@" ; \
|
||||
("$$@" || touch $$failed) 2>&1 | tee -a $(CVSCO_LOGFILE) && \
|
||||
if test -f $$failed; then false; else true; fi; }; \
|
||||
cvs_co $(CVSCO_NSPR) && \
|
||||
cvs_co $(CVSCO_NSS) && \
|
||||
cvs_co $(CVSCO_PSM) && \
|
||||
cvs_co $(CVSCO_LDAPCSDK) && \
|
||||
cvs_co $(CVSCO_ACCESSIBLE) && \
|
||||
cvs_co $(CVSCO_GFX2) && \
|
||||
cvs_co $(CVSCO_IMGLIB2) && \
|
||||
$(CHECKOUT_CALENDAR) && \
|
||||
$(CHECKOUT_LIBART) && \
|
||||
cvs_co $(CVSCO_SEAMONKEY) && \
|
||||
cvs_co $(CVSCO_NOSUBDIRS)
|
||||
@echo "checkout finish: "`date` | tee -a $(CVSCO_LOGFILE)
|
||||
# @: Check the log for conflicts. ;
|
||||
@conflicts=`egrep "^C " $(CVSCO_LOGFILE)` ;\
|
||||
if test "$$conflicts" ; then \
|
||||
echo "$(MAKE): *** Conflicts during checkout." ;\
|
||||
echo "$$conflicts" ;\
|
||||
echo "$(MAKE): Refer to $(CVSCO_LOGFILE) for full log." ;\
|
||||
false; \
|
||||
else true; \
|
||||
fi
|
||||
ifdef RUN_AUTOCONF_LOCALLY
|
||||
@echo Generating configures using $(AUTOCONF) ; \
|
||||
cd $(TOPSRCDIR) && $(AUTOCONF) && \
|
||||
cd $(TOPSRCDIR)/nsprpub && $(AUTOCONF) && \
|
||||
cd $(TOPSRCDIR)/directory/c-sdk && $(AUTOCONF)
|
||||
endif
|
||||
|
||||
fast-update:
|
||||
# @: Backup the last checkout log.
|
||||
@if test -f $(CVSCO_LOGFILE) ; then \
|
||||
mv $(CVSCO_LOGFILE) $(CVSCO_LOGFILE).old; \
|
||||
else true; \
|
||||
fi
|
||||
ifdef RUN_AUTOCONF_LOCALLY
|
||||
@echo "Removing local configures" ; \
|
||||
cd $(ROOTDIR) && \
|
||||
$(RM) -f mozilla/configure mozilla/nsprpub/configure \
|
||||
mozilla/directory/c-sdk/configure
|
||||
endif
|
||||
@echo "checkout start: "`date` | tee $(CVSCO_LOGFILE)
|
||||
@echo '$(CVSCO) mozilla/client.mk mozilla/build/unix/modules.mk'; \
|
||||
cd $(ROOTDIR) && \
|
||||
$(CVSCO) mozilla/client.mk mozilla/build/unix/modules.mk
|
||||
@cd $(TOPSRCDIR) && \
|
||||
$(MAKE) -f client.mk real_fast-update
|
||||
|
||||
real_fast-update:
|
||||
# @: Start the update. Split the output to the tty and a log file. \
|
||||
# : If it fails, touch an error file because "tee" hides the error.
|
||||
@failed=.fast_update-failed.tmp; rm -f $$failed*; \
|
||||
fast_update() { (config/cvsco-fast-update.pl $$@ || touch $$failed) 2>&1 | tee -a $(CVSCO_LOGFILE) && \
|
||||
if test -f $$failed; then false; else true; fi; }; \
|
||||
cvs_co() { echo "$$@" ; \
|
||||
("$$@" || touch $$failed) 2>&1 | tee -a $(CVSCO_LOGFILE) && \
|
||||
if test -f $$failed; then false; else true; fi; }; \
|
||||
fast_update $(CVSCO_NSPR) && \
|
||||
cd $(ROOTDIR) && \
|
||||
failed=mozilla/.fast_update-failed.tmp && \
|
||||
cvs_co $(CVSCO_NSS) && \
|
||||
failed=.fast_update-failed.tmp && \
|
||||
cd mozilla && \
|
||||
fast_update $(CVSCO_PSM) && \
|
||||
fast_update $(CVSCO_LDAPCSDK) && \
|
||||
fast_update $(CVSCO_ACCESSIBLE) && \
|
||||
fast_update $(CVSCO_GFX2) && \
|
||||
fast_update $(CVSCO_IMGLIB2) && \
|
||||
$(FASTUPDATE_CALENDAR) && \
|
||||
$(FASTUPDATE_LIBART) && \
|
||||
fast_update $(CVSCO_SEAMONKEY) && \
|
||||
fast_update $(CVSCO_NOSUBDIRS)
|
||||
@echo "fast_update finish: "`date` | tee -a $(CVSCO_LOGFILE)
|
||||
# @: Check the log for conflicts. ;
|
||||
@conflicts=`egrep "^C " $(CVSCO_LOGFILE)` ;\
|
||||
if test "$$conflicts" ; then \
|
||||
echo "$(MAKE): *** Conflicts during fast-update." ;\
|
||||
echo "$$conflicts" ;\
|
||||
echo "$(MAKE): Refer to $(CVSCO_LOGFILE) for full log." ;\
|
||||
false; \
|
||||
else true; \
|
||||
fi
|
||||
ifdef RUN_AUTOCONF_LOCALLY
|
||||
@echo Generating configures using $(AUTOCONF) ; \
|
||||
cd $(TOPSRCDIR) && $(AUTOCONF) && \
|
||||
cd $(TOPSRCDIR)/nsprpub && $(AUTOCONF) && \
|
||||
cd $(TOPSRCDIR)/directory/c-sdk && $(AUTOCONF)
|
||||
endif
|
||||
|
||||
####################################
|
||||
# Web configure
|
||||
|
||||
WEBCONFIG_FILE := $(HOME)/.mozconfig
|
||||
|
||||
MOZCONFIG2CONFIGURATOR := build/autoconf/mozconfig2configurator
|
||||
webconfig:
|
||||
@cd $(TOPSRCDIR); \
|
||||
url=`$(MOZCONFIG2CONFIGURATOR) $(TOPSRCDIR)`; \
|
||||
echo Running mozilla with the following url: ;\
|
||||
echo ;\
|
||||
echo $$url ;\
|
||||
mozilla -remote "openURL($$url)" || \
|
||||
netscape -remote "openURL($$url)" || \
|
||||
mozilla $$url || \
|
||||
netscape $$url ;\
|
||||
echo ;\
|
||||
echo 1. Fill out the form on the browser. ;\
|
||||
echo 2. Save the results to $(WEBCONFIG_FILE)
|
||||
|
||||
#####################################################
|
||||
# First Checkout
|
||||
|
||||
ifdef _IS_FIRST_CHECKOUT
|
||||
# First time, do build target in a new process to pick up new files.
|
||||
build::
|
||||
$(MAKE) -f $(TOPSRCDIR)/client.mk build
|
||||
else
|
||||
|
||||
#####################################################
|
||||
# After First Checkout
|
||||
|
||||
|
||||
####################################
|
||||
# Configure
|
||||
|
||||
CONFIG_STATUS := $(wildcard $(OBJDIR)/config.status)
|
||||
CONFIG_CACHE := $(wildcard $(OBJDIR)/config.cache)
|
||||
|
||||
ifdef RUN_AUTOCONF_LOCALLY
|
||||
EXTRA_CONFIG_DEPS := \
|
||||
$(TOPSRCDIR)/aclocal.m4 \
|
||||
$(wildcard $(TOPSRCDIR)/build/autoconf/*.m4) \
|
||||
$(NULL)
|
||||
|
||||
$(TOPSRCDIR)/configure: $(TOPSRCDIR)/configure.in $(EXTRA_CONFIG_DEPS)
|
||||
@echo Generating $@ using autoconf
|
||||
cd $(TOPSRCDIR); $(AUTOCONF)
|
||||
endif
|
||||
|
||||
CONFIG_STATUS_DEPS_L10N := $(wildcard $(TOPSRCDIR)/l10n/makefiles.all)
|
||||
|
||||
CONFIG_STATUS_DEPS := \
|
||||
$(TOPSRCDIR)/configure \
|
||||
$(TOPSRCDIR)/allmakefiles.sh \
|
||||
$(TOPSRCDIR)/.mozconfig.mk \
|
||||
$(wildcard $(TOPSRCDIR)/nsprpub/configure) \
|
||||
$(wildcard $(TOPSRCDIR)/directory/c-sdk/configure) \
|
||||
$(wildcard $(TOPSRCDIR)/mailnews/makefiles) \
|
||||
$(CONFIG_STATUS_DEPS_L10N) \
|
||||
$(wildcard $(TOPSRCDIR)/themes/makefiles) \
|
||||
$(NULL)
|
||||
|
||||
# configure uses the program name to determine @srcdir@. Calling it without
|
||||
# $(TOPSRCDIR) will set @srcdir@ to "."; otherwise, it is set to the full
|
||||
# path of $(TOPSRCDIR).
|
||||
ifeq ($(TOPSRCDIR),$(OBJDIR))
|
||||
CONFIGURE := ./configure
|
||||
else
|
||||
CONFIGURE := $(TOPSRCDIR)/configure
|
||||
endif
|
||||
|
||||
ifdef _OBJ2SRCPATH
|
||||
CONFIGURE_ARGS := --srcdir=$(_OBJ2SRCPATH) $(CONFIGURE_ARGS)
|
||||
endif
|
||||
|
||||
$(OBJDIR)/Makefile $(OBJDIR)/config.status: $(CONFIG_STATUS_DEPS)
|
||||
@if test ! -d $(OBJDIR); then $(MKDIR) $(OBJDIR); else true; fi
|
||||
@echo cd $(OBJDIR);
|
||||
@echo $(CONFIGURE) $(CONFIGURE_ARGS)
|
||||
@cd $(OBJDIR) && $(CONFIGURE_ENV_ARGS) $(CONFIGURE) $(CONFIGURE_ARGS) \
|
||||
|| ( echo "*** Fix above errors and then restart with\
|
||||
\"$(MAKE) -f client.mk build\"" && exit 1 )
|
||||
@touch $(OBJDIR)/Makefile
|
||||
|
||||
ifdef CONFIG_STATUS
|
||||
$(OBJDIR)/config/autoconf.mk: $(TOPSRCDIR)/config/autoconf.mk.in
|
||||
cd $(OBJDIR); \
|
||||
CONFIG_FILES=config/autoconf.mk ./config.status
|
||||
endif
|
||||
|
||||
|
||||
####################################
|
||||
# Depend
|
||||
|
||||
depend:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
|
||||
$(MOZ_MAKE) export && $(MOZ_MAKE) depend
|
||||
|
||||
####################################
|
||||
# Build it
|
||||
|
||||
build:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
|
||||
$(MOZ_MAKE)
|
||||
|
||||
####################################
|
||||
# Other targets
|
||||
|
||||
# Pass these target onto the real build system
|
||||
install export libs clean realclean distclean alldep:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
|
||||
$(MOZ_MAKE) $@
|
||||
|
||||
cleansrcdir:
|
||||
@cd $(TOPSRCDIR); \
|
||||
if [ -f webshell/embed/gtk/Makefile ]; then \
|
||||
$(MAKE) -C webshell/embed/gtk distclean; \
|
||||
fi; \
|
||||
if [ -f Makefile ]; then \
|
||||
$(MAKE) distclean ; \
|
||||
else \
|
||||
echo "Removing object files from srcdir..."; \
|
||||
rm -fr `find . -type d \( -name .deps -print -o -name CVS \
|
||||
-o -exec test ! -d {}/CVS \; \) -prune \
|
||||
-o \( -name '*.[ao]' -o -name '*.so' \) -type f -print`; \
|
||||
build/autoconf/clean-config.sh; \
|
||||
fi;
|
||||
|
||||
# (! IS_FIRST_CHECKOUT)
|
||||
endif
|
||||
|
||||
.PHONY: checkout real_checkout depend build export libs alldep install clean realclean distclean cleansrcdir pull_all build_all clobber clobber_all pull_and_build_all everything
|
||||
1812
mozilla/cmd/dialup/as_html/help/fppphlp.htm
Normal file
BIN
mozilla/cmd/dialup/as_html/help/images/fppp1.gif
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
mozilla/cmd/dialup/as_html/help/images/fppp10.gif
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
mozilla/cmd/dialup/as_html/help/images/fppp11.gif
Normal file
|
After Width: | Height: | Size: 8.0 KiB |
BIN
mozilla/cmd/dialup/as_html/help/images/fppp12.gif
Normal file
|
After Width: | Height: | Size: 6.3 KiB |
BIN
mozilla/cmd/dialup/as_html/help/images/fppp14.gif
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
mozilla/cmd/dialup/as_html/help/images/fppp2.gif
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
mozilla/cmd/dialup/as_html/help/images/fppp3.gif
Normal file
|
After Width: | Height: | Size: 8.2 KiB |
BIN
mozilla/cmd/dialup/as_html/help/images/fppp4.gif
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
BIN
mozilla/cmd/dialup/as_html/help/images/fppp5.gif
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
mozilla/cmd/dialup/as_html/help/images/fppp6.gif
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
mozilla/cmd/dialup/as_html/help/images/fppp7.gif
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
mozilla/cmd/dialup/as_html/help/images/fppp8.gif
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
mozilla/cmd/dialup/as_html/help/images/fppp9.gif
Normal file
|
After Width: | Height: | Size: 7.7 KiB |
75
mozilla/cmd/xfe/hot.c
Normal file
@@ -0,0 +1,75 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* */
|
||||
/* hot.c --- bookmarks dialogs
|
||||
Created: Terry Weissman <terry@netscape.com>, 20-Jul-95.
|
||||
*/
|
||||
|
||||
|
||||
#include "mozilla.h"
|
||||
#include "xfe.h"
|
||||
#include "bkmks.h"
|
||||
|
||||
extern MWContext *fe_getBookmarkContext();
|
||||
|
||||
Boolean
|
||||
fe_SaveBookmarks (void)
|
||||
{
|
||||
if (fe_getBookmarkContext())
|
||||
if (BM_SaveBookmarks(fe_getBookmarkContext(), NULL) < 0)
|
||||
return False;
|
||||
return True;
|
||||
}
|
||||
|
||||
void
|
||||
fe_AddToBookmark (MWContext *context, const char *title, URL_Struct *url,
|
||||
time_t time)
|
||||
{
|
||||
BM_Entry *bm;
|
||||
const char *new_title;
|
||||
MWContext *bmcontext = NULL;
|
||||
|
||||
|
||||
if (!title || !*title) new_title = url->address;
|
||||
else new_title = title;
|
||||
bm = (BM_Entry*) BM_NewUrl(new_title, url->address, NULL, time);
|
||||
|
||||
bmcontext = fe_getBookmarkContext();
|
||||
BM_AppendToHeader (bmcontext, BM_GetAddHeader(bmcontext), bm);
|
||||
}
|
||||
|
||||
void
|
||||
fe_AddBookmarkCallback (Widget widget, XtPointer closure, XtPointer call_data)
|
||||
{
|
||||
MWContext *context = (MWContext *) closure;
|
||||
History_entry *h = SHIST_GetCurrent (&context->hist);
|
||||
BM_Entry *bm;
|
||||
MWContext *bmcontext = NULL;
|
||||
char *new_title;
|
||||
|
||||
if (!h) return;
|
||||
|
||||
if (!h->title || !*h->title) new_title = h->address;
|
||||
else new_title = h->title;
|
||||
bm = (BM_Entry*)BM_NewUrl( new_title, h->address, NULL, h->last_access);
|
||||
|
||||
fe_UserActivity (context);
|
||||
|
||||
bmcontext = fe_getBookmarkContext();
|
||||
BM_AppendToHeader (bmcontext, BM_GetAddHeader(bmcontext), bm);
|
||||
}
|
||||
1954
mozilla/cmd/xfe/src/BookmarkBase.cpp
Normal file
243
mozilla/cmd/xfe/src/BookmarkFindDialog.cpp
Normal file
@@ -0,0 +1,243 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
BookmarkFindDialog.cpp -- dialog for finding bookmarks (duh).
|
||||
Created: Chris Toshok <toshok@netscape.com>, 12-Mar-97.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "structs.h"
|
||||
#include "xp_core.h"
|
||||
|
||||
#include "BookmarkFrame.h"
|
||||
#include "BookmarkFindDialog.h"
|
||||
#include <Xm/XmP.h>
|
||||
#include <Xm/LabelG.h>
|
||||
#include <Xm/ToggleBG.h>
|
||||
|
||||
#include <Xfe/Xfe.h>
|
||||
|
||||
#include "xfe.h"
|
||||
#include "felocale.h"
|
||||
|
||||
/* we only have one instance of the bookmark find dialog up at at any given time. */
|
||||
static XFE_BookmarkFindDialog *theDialog = NULL;
|
||||
|
||||
XFE_BookmarkFindDialog::XFE_BookmarkFindDialog(Widget parent,
|
||||
BM_FindInfo *info)
|
||||
: XFE_Dialog(parent,
|
||||
"findDialog",
|
||||
TRUE, // ok
|
||||
TRUE, // cancel
|
||||
FALSE, // help
|
||||
TRUE, //apply
|
||||
TRUE, //separator
|
||||
FALSE // modal
|
||||
)
|
||||
{
|
||||
Widget form;
|
||||
Arg av[10];
|
||||
int ac;
|
||||
Widget findlabel, lookinlabel, helplabel;
|
||||
|
||||
m_findInfo = info;
|
||||
|
||||
form = XmCreateForm(m_chrome, "bmFindForm", NULL, 0);
|
||||
|
||||
XtManageChild(form);
|
||||
|
||||
XtAddCallback(m_chrome, XmNokCallback, find_cb, this);
|
||||
XtAddCallback(m_chrome, XmNcancelCallback, cancel_cb, this);
|
||||
XtAddCallback(m_chrome, XmNapplyCallback, clear_cb, this);
|
||||
|
||||
findlabel = XtCreateManagedWidget("findLabel",
|
||||
xmLabelGadgetClass,
|
||||
form,
|
||||
NULL, 0);
|
||||
|
||||
m_findText = fe_CreateTextField(form, "findText", NULL, 0);
|
||||
XtManageChild(m_findText);
|
||||
|
||||
lookinlabel = XtCreateManagedWidget("lookinLabel",
|
||||
xmLabelGadgetClass,
|
||||
form,
|
||||
NULL, 0);
|
||||
|
||||
if (XfeWidth(findlabel) < XfeWidth(lookinlabel))
|
||||
XtVaSetValues (findlabel, XmNwidth, XfeWidth(lookinlabel), 0);
|
||||
else
|
||||
XtVaSetValues (lookinlabel, XmNwidth, XfeWidth(findlabel), 0);
|
||||
|
||||
ac = 0;
|
||||
XtSetArg(av[ac], XmNindicatorType, XmN_OF_MANY); ac++;
|
||||
m_nameToggle = XtCreateManagedWidget("nameToggle",
|
||||
xmToggleButtonGadgetClass, form, av, ac);
|
||||
m_locationToggle = XtCreateManagedWidget("locationToggle",
|
||||
xmToggleButtonGadgetClass, form, av, ac);
|
||||
m_descriptionToggle = XtCreateManagedWidget("descriptionToggle",
|
||||
xmToggleButtonGadgetClass, form, av, ac);
|
||||
m_caseToggle = XtCreateManagedWidget("caseSensitive",
|
||||
xmToggleButtonGadgetClass, form, av, ac);
|
||||
m_wordToggle = XtCreateManagedWidget("wordToggle",
|
||||
xmToggleButtonGadgetClass, form, av, ac);
|
||||
|
||||
ac = 0;
|
||||
XtSetArg(av[ac], XmNentryAlignment, XmALIGNMENT_CENTER); ac++;
|
||||
|
||||
helplabel = XtCreateManagedWidget("helptext",
|
||||
xmLabelGadgetClass, form, av, ac);
|
||||
|
||||
/* Attachments */
|
||||
XtVaSetValues(findlabel, XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNtopAttachment, XmATTACH_FORM, 0);
|
||||
|
||||
XtVaSetValues(m_findText, XmNleftAttachment, XmATTACH_WIDGET,
|
||||
XmNleftWidget, findlabel,
|
||||
XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
|
||||
XmNtopWidget, findlabel,
|
||||
XmNrightAttachment, XmATTACH_FORM, 0);
|
||||
|
||||
XtVaSetValues(lookinlabel, XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, m_findText, 0);
|
||||
|
||||
XtVaSetValues(m_nameToggle, XmNleftAttachment, XmATTACH_WIDGET,
|
||||
XmNleftWidget, lookinlabel,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, m_findText, 0);
|
||||
|
||||
XtVaSetValues(m_locationToggle, XmNleftAttachment, XmATTACH_WIDGET,
|
||||
XmNleftWidget, m_nameToggle,
|
||||
XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
|
||||
XmNtopWidget, m_nameToggle, 0);
|
||||
|
||||
XtVaSetValues(m_descriptionToggle, XmNleftAttachment, XmATTACH_WIDGET,
|
||||
XmNleftWidget, m_locationToggle,
|
||||
XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
|
||||
XmNtopWidget, m_nameToggle, 0);
|
||||
|
||||
XtVaSetValues(m_caseToggle, XmNleftAttachment, XmATTACH_WIDGET,
|
||||
XmNleftWidget, lookinlabel,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, m_nameToggle, 0);
|
||||
|
||||
XtVaSetValues(m_wordToggle, XmNleftAttachment, XmATTACH_WIDGET,
|
||||
XmNleftWidget, lookinlabel,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, m_caseToggle, 0);
|
||||
|
||||
XtVaSetValues(helplabel, XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, m_wordToggle, 0);
|
||||
|
||||
XtVaSetValues (m_chrome, XmNinitialFocus, m_findText, 0);
|
||||
|
||||
setValues();
|
||||
}
|
||||
|
||||
XFE_BookmarkFindDialog::~XFE_BookmarkFindDialog()
|
||||
{
|
||||
theDialog = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkFindDialog::getValues()
|
||||
{
|
||||
/* Should we free findInfo->textToFind */
|
||||
XP_FREE(m_findInfo->textToFind);
|
||||
m_findInfo->textToFind = fe_GetTextField(m_findText);
|
||||
|
||||
XtVaGetValues(m_nameToggle, XmNset, &m_findInfo->checkName, 0);
|
||||
XtVaGetValues(m_locationToggle, XmNset, &m_findInfo->checkLocation, 0);
|
||||
XtVaGetValues(m_descriptionToggle, XmNset, &m_findInfo->checkDescription, 0);
|
||||
XtVaGetValues(m_caseToggle, XmNset, &m_findInfo->matchCase, 0);
|
||||
XtVaGetValues(m_wordToggle, XmNset, &m_findInfo->matchWholeWord, 0);
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkFindDialog::setValues()
|
||||
{
|
||||
fe_SetTextField(m_findText, m_findInfo->textToFind);
|
||||
|
||||
XtVaSetValues(m_nameToggle, XmNset, m_findInfo->checkName, 0);
|
||||
XtVaSetValues(m_locationToggle, XmNset, m_findInfo->checkLocation, 0);
|
||||
XtVaSetValues(m_descriptionToggle, XmNset, m_findInfo->checkDescription, 0);
|
||||
XtVaSetValues(m_caseToggle, XmNset, m_findInfo->matchCase, 0);
|
||||
XtVaSetValues(m_wordToggle, XmNset, m_findInfo->matchWholeWord, 0);
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkFindDialog::find()
|
||||
{
|
||||
getValues();
|
||||
hide();
|
||||
|
||||
BM_DoFindBookmark(XFE_BookmarkFrame::main_bm_context, m_findInfo);
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkFindDialog::clear()
|
||||
{
|
||||
if (m_findInfo->textToFind)
|
||||
m_findInfo->textToFind[0] = '\0';
|
||||
fe_SetTextField(m_findText, m_findInfo->textToFind);
|
||||
XmProcessTraversal (m_findText, XmTRAVERSE_CURRENT);
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkFindDialog::cancel()
|
||||
{
|
||||
hide();
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkFindDialog::find_cb(Widget, XtPointer clientData, XtPointer)
|
||||
{
|
||||
XFE_BookmarkFindDialog *obj = (XFE_BookmarkFindDialog*)clientData;
|
||||
|
||||
obj->find();
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkFindDialog::clear_cb(Widget, XtPointer clientData, XtPointer)
|
||||
{
|
||||
XFE_BookmarkFindDialog *obj = (XFE_BookmarkFindDialog*)clientData;
|
||||
|
||||
obj->clear();
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkFindDialog::cancel_cb(Widget, XtPointer clientData, XtPointer)
|
||||
{
|
||||
XFE_BookmarkFindDialog *obj = (XFE_BookmarkFindDialog*)clientData;
|
||||
|
||||
obj->cancel();
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
fe_showBMFindDialog(Widget parent, BM_FindInfo *info)
|
||||
{
|
||||
if (!theDialog)
|
||||
{
|
||||
theDialog = new XFE_BookmarkFindDialog(parent, info);
|
||||
}
|
||||
|
||||
theDialog->show();
|
||||
}
|
||||
60
mozilla/cmd/xfe/src/BookmarkFindDialog.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
BookmarkFindDialog.h -- dialog for finding bookmarks (duh).
|
||||
Created: Chris Toshok <toshok@netscape.com>, 12-Mar-97.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _xfe_bookmarkfinddialog_h
|
||||
#define _xfe_bookmarkfinddialog_h
|
||||
|
||||
#include "Dialog.h"
|
||||
#include "bkmks.h"
|
||||
|
||||
class XFE_BookmarkFindDialog : public XFE_Dialog
|
||||
{
|
||||
public:
|
||||
XFE_BookmarkFindDialog(Widget parent,
|
||||
BM_FindInfo *info);
|
||||
|
||||
virtual ~XFE_BookmarkFindDialog();
|
||||
|
||||
private:
|
||||
Widget m_findText;
|
||||
Widget m_nameToggle, m_locationToggle, m_descriptionToggle;
|
||||
Widget m_caseToggle, m_wordToggle;
|
||||
|
||||
BM_FindInfo *m_findInfo;
|
||||
|
||||
void find();
|
||||
void clear();
|
||||
void cancel();
|
||||
|
||||
void getValues(); // fills in m_findInfo
|
||||
void setValues(); // alters UI to match m_findInfo
|
||||
|
||||
static void find_cb(Widget, XtPointer, XtPointer);
|
||||
static void clear_cb(Widget, XtPointer, XtPointer);
|
||||
static void cancel_cb(Widget, XtPointer, XtPointer);
|
||||
};
|
||||
|
||||
extern "C" void fe_showBMFindDialog(Widget parent, BM_FindInfo *info);
|
||||
|
||||
#endif /* xfe_bookmarkfinddialog_h */
|
||||
417
mozilla/cmd/xfe/src/BookmarkPropDialog.cpp
Normal file
@@ -0,0 +1,417 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
BookmarkPropDialog.cpp -- Dialog to edit bookmark properties.
|
||||
Created: Stephen Lamm <slamm@netscape.com>, 10-Mar-97.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "BookmarkPropDialog.h"
|
||||
#include "BookmarkView.h"
|
||||
|
||||
#include "bkmks.h"
|
||||
#include "felocale.h" // for fe_GetTextField()
|
||||
#include "xfe.h"
|
||||
#include "xfe2_extern.h"
|
||||
#include "xpgetstr.h"
|
||||
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/LabelG.h>
|
||||
#include <Xm/PushBG.h>
|
||||
#include <Xm/SelectioB.h>
|
||||
#include <Xm/TextF.h>
|
||||
|
||||
extern int XFE_BM_ALIAS; // "This is an alias to the following Bookmark:"
|
||||
|
||||
XFE_BookmarkPropDialog::XFE_BookmarkPropDialog(MWContext *context, Widget parent)
|
||||
: XFE_Dialog(parent, "bookmarkProps",
|
||||
TRUE, // ok
|
||||
TRUE, // cancel
|
||||
FALSE, // help
|
||||
FALSE, // apply
|
||||
TRUE, // Separator
|
||||
FALSE // Modal
|
||||
)
|
||||
{
|
||||
int ac;
|
||||
Arg av[20];
|
||||
Widget kids[20];
|
||||
int i;
|
||||
|
||||
m_context = context;
|
||||
m_entry = NULL;
|
||||
|
||||
Widget form = 0;
|
||||
Widget name_label = 0;
|
||||
Widget description_label = 0;
|
||||
Widget addedOn_label = 0;
|
||||
|
||||
|
||||
fe_UnmanageChild_safe (XmSelectionBoxGetChild (m_chrome,
|
||||
XmDIALOG_SELECTION_LABEL));
|
||||
fe_UnmanageChild_safe (XmSelectionBoxGetChild (m_chrome,
|
||||
XmDIALOG_TEXT));
|
||||
fe_UnmanageChild_safe (XmSelectionBoxGetChild (m_chrome,
|
||||
XmDIALOG_APPLY_BUTTON));
|
||||
fe_UnmanageChild_safe (XmSelectionBoxGetChild (m_chrome,
|
||||
XmDIALOG_HELP_BUTTON));
|
||||
|
||||
XtAddCallback(m_chrome, XmNdestroyCallback, destroy_cb, this);
|
||||
XtAddCallback(m_chrome, XmNokCallback, ok_cb, this);
|
||||
XtAddCallback(m_chrome, XmNcancelCallback, close_cb, this);
|
||||
|
||||
ac = 0;
|
||||
form = XmCreateForm (m_chrome, "form", av, ac);
|
||||
m_title = XmCreateLabelGadget(form, "title", av, ac);
|
||||
m_aliasLabel = XmCreateLabelGadget(form, "aliasLabel", av, ac);
|
||||
m_aliasButton = XmCreatePushButtonGadget (form, "aliasButton", av, ac);
|
||||
name_label = XmCreateLabelGadget(form, "nameLabel", av, ac);
|
||||
m_locationLabel = XmCreateLabelGadget(form, "locationLabel", av, ac);
|
||||
description_label = XmCreateLabelGadget(form, "descriptionLabel", av, ac);
|
||||
|
||||
if (m_context->type == MWContextBookmarks) {
|
||||
m_lastVisitedLabel = XmCreateLabelGadget(form, "lastvisitedLabel", av, ac);
|
||||
addedOn_label = XmCreateLabelGadget(form, "addedonLabel", av, ac);
|
||||
|
||||
}
|
||||
|
||||
XtAddCallback(m_aliasButton, XmNactivateCallback, selectalias_cb, this);
|
||||
|
||||
ac = 0;
|
||||
m_name = fe_CreateTextField(form, "nameText", av, ac);
|
||||
m_location = fe_CreateTextField(form, "locationText", av, ac);
|
||||
|
||||
ac = 0;
|
||||
XtSetArg (av[ac], XmNeditMode, XmMULTI_LINE_EDIT); ac++;
|
||||
m_description = fe_CreateText(form, "descriptionText", av, ac);
|
||||
|
||||
ac = 0;
|
||||
m_lastVisited = XmCreateLabelGadget(form, "lastVisited", av, ac);
|
||||
m_addedOn = XmCreateLabelGadget(form, "addedOn", av, ac);
|
||||
|
||||
XtVaSetValues(m_title,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
0);
|
||||
XtVaSetValues(name_label,
|
||||
XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
|
||||
XmNtopWidget, m_name,
|
||||
XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
|
||||
XmNbottomWidget, m_name,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_WIDGET,
|
||||
XmNrightWidget, m_name,
|
||||
0);
|
||||
XtVaSetValues(m_locationLabel,
|
||||
XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
|
||||
XmNtopWidget, m_location,
|
||||
XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
|
||||
XmNbottomWidget, m_location,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_WIDGET,
|
||||
XmNrightWidget, m_location,
|
||||
0);
|
||||
XtVaSetValues(description_label,
|
||||
XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
|
||||
XmNtopWidget, m_description,
|
||||
XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
|
||||
XmNbottomWidget, m_description,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_WIDGET,
|
||||
XmNrightWidget, m_description,
|
||||
0);
|
||||
XtVaSetValues(m_lastVisitedLabel,
|
||||
XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
|
||||
XmNtopWidget, m_lastVisited,
|
||||
XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
|
||||
XmNbottomWidget, m_lastVisited,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_WIDGET,
|
||||
XmNrightWidget, m_lastVisited,
|
||||
0);
|
||||
XtVaSetValues(addedOn_label,
|
||||
XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
|
||||
XmNtopWidget, m_addedOn,
|
||||
XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
|
||||
XmNbottomWidget, m_addedOn,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_WIDGET,
|
||||
XmNrightWidget, m_addedOn,
|
||||
0);
|
||||
ac = 0;
|
||||
kids[ac++] = m_title;
|
||||
kids[ac++] = m_name;
|
||||
kids[ac++] = m_location;
|
||||
kids[ac++] = m_description;
|
||||
kids[ac++] = m_lastVisited;
|
||||
kids[ac++] = m_addedOn;
|
||||
XtVaSetValues(kids[1],
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, kids[0],
|
||||
XmNleftAttachment, XmATTACH_NONE,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_NONE,
|
||||
0);
|
||||
for (i=2 ; i<ac ; i++) {
|
||||
XtVaSetValues(kids[i],
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, kids[i-1],
|
||||
XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
|
||||
XmNleftWidget, kids[i-1],
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_NONE,
|
||||
0);
|
||||
}
|
||||
XtVaSetValues(m_aliasLabel,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, kids[ac-1],
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_WIDGET,
|
||||
XmNrightWidget, m_aliasButton,
|
||||
0);
|
||||
XtVaSetValues(m_aliasButton,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, kids[ac-1],
|
||||
XmNleftAttachment, XmATTACH_NONE,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
0);
|
||||
|
||||
fe_attach_field_to_labels(m_name, name_label, m_locationLabel,
|
||||
description_label, m_lastVisitedLabel,
|
||||
addedOn_label, 0);
|
||||
|
||||
kids[ac++] = m_aliasLabel;
|
||||
kids[ac++] = m_aliasButton;
|
||||
kids[ac++] = name_label;
|
||||
kids[ac++] = m_locationLabel;
|
||||
kids[ac++] = description_label;
|
||||
kids[ac++] = m_lastVisitedLabel;
|
||||
kids[ac++] = addedOn_label;
|
||||
|
||||
XtManageChildren(kids, ac);
|
||||
XtManageChild(form);
|
||||
|
||||
fe_HackDialogTranslations (m_chrome);
|
||||
}
|
||||
|
||||
XFE_BookmarkPropDialog::~XFE_BookmarkPropDialog()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkPropDialog::selectAlias()
|
||||
{
|
||||
if (m_entry)
|
||||
BM_SelectAliases(m_context, m_entry);
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkPropDialog::selectalias_cb(Widget widget,
|
||||
XtPointer closure, XtPointer call_data)
|
||||
{
|
||||
XFE_BookmarkPropDialog* obj = (XFE_BookmarkPropDialog *)closure;
|
||||
obj->selectAlias();
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkPropDialog::destroy_cb(Widget widget,
|
||||
XtPointer closure, XtPointer call_data)
|
||||
{
|
||||
XFE_BookmarkPropDialog* obj = (XFE_BookmarkPropDialog *)closure;
|
||||
|
||||
obj->close();
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkPropDialog::close()
|
||||
{
|
||||
if (m_entry)
|
||||
{
|
||||
BM_CancelEdit(m_context, m_entry);
|
||||
m_entry = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkPropDialog::close_cb(Widget widget,
|
||||
XtPointer closure, XtPointer call_data)
|
||||
{
|
||||
XFE_BookmarkPropDialog* obj = (XFE_BookmarkPropDialog *)closure;
|
||||
|
||||
obj->close();
|
||||
|
||||
XtDestroyWidget(obj->getBaseWidget());
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkPropDialog::ok()
|
||||
{
|
||||
if (m_entry)
|
||||
{
|
||||
commitChanges();
|
||||
m_entry = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkPropDialog::ok_cb(Widget widget,
|
||||
XtPointer closure, XtPointer call_data)
|
||||
{
|
||||
XFE_BookmarkPropDialog* obj = (XFE_BookmarkPropDialog *)closure;
|
||||
|
||||
obj->ok();
|
||||
|
||||
XtDestroyWidget(obj->getBaseWidget());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
XFE_BookmarkPropDialog::editItem(BM_Entry *entry)
|
||||
{
|
||||
const char* str;
|
||||
char* tmp;
|
||||
|
||||
/* Raise the edit shell to view */
|
||||
if (XtIsManaged (CONTEXT_WIDGET (m_context))) {
|
||||
XRaiseWindow(XtDisplay(CONTEXT_WIDGET (m_context)),
|
||||
XtWindow(CONTEXT_WIDGET (m_context)));
|
||||
}
|
||||
|
||||
commitChanges();
|
||||
|
||||
/* Alias stuff */
|
||||
if (BM_IsAlias(entry)) {
|
||||
fe_SetString(m_title, XmNlabelString, XP_GetString(XFE_BM_ALIAS));
|
||||
entry = BM_GetAliasOriginal(entry);
|
||||
}
|
||||
else
|
||||
fe_SetString(m_title, XmNlabelString, " ");
|
||||
|
||||
m_entry = entry;
|
||||
|
||||
if (BM_IsUrl(entry)) {
|
||||
str = BM_GetName(entry);
|
||||
fe_SetTextField(m_name, str?str:"");
|
||||
str = BM_GetAddress(entry);
|
||||
fe_SetTextField(m_location, str?str:"");
|
||||
XtVaSetValues(m_location, XmNsensitive, True, 0);
|
||||
XtVaSetValues(m_locationLabel, XmNsensitive, True, 0);
|
||||
str = BM_GetDescription(entry);
|
||||
fe_SetTextField(m_description, str?str:"");
|
||||
tmp = BM_PrettyLastVisitedDate(entry);
|
||||
if (!tmp || !*tmp) tmp = " ";
|
||||
fe_SetString(m_lastVisited, XmNlabelString, tmp);
|
||||
XtVaSetValues(m_lastVisited, XmNsensitive, True, 0);
|
||||
XtVaSetValues(m_lastVisitedLabel, XmNsensitive, True, 0);
|
||||
fe_SetString(m_addedOn, XmNlabelString, BM_PrettyAddedOnDate(entry));
|
||||
fe_SetString(m_aliasLabel, XmNlabelString,
|
||||
BM_PrettyAliasCount(m_context, entry));
|
||||
if (BM_CountAliases(m_context, entry) > 0)
|
||||
XtVaSetValues(m_aliasButton, XmNsensitive, True, 0);
|
||||
else
|
||||
XtVaSetValues(m_aliasButton, XmNsensitive, False, 0);
|
||||
}
|
||||
else if (BM_IsHeader(entry)) {
|
||||
str = BM_GetName(entry);
|
||||
fe_SetTextField(m_name, str?str:"");
|
||||
fe_SetTextField(m_location, "");
|
||||
XtVaSetValues(m_location, XmNsensitive, False, 0);
|
||||
XtVaSetValues(m_locationLabel, XmNsensitive, False, 0);
|
||||
str = BM_GetDescription(entry);
|
||||
fe_SetTextField(m_description, str?str:"");
|
||||
fe_SetString(m_lastVisited, XmNlabelString, " ");
|
||||
XtVaSetValues(m_lastVisited, XmNsensitive, False, 0);
|
||||
XtVaSetValues(m_lastVisitedLabel, XmNsensitive, False, 0);
|
||||
fe_SetString(m_addedOn, XmNlabelString, BM_PrettyAddedOnDate(entry));
|
||||
fe_SetString(m_aliasLabel, XmNlabelString, "" );
|
||||
XtVaSetValues(m_aliasButton, XmNsensitive, False, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkPropDialog::entryGoingAway(BM_Entry *entry)
|
||||
{
|
||||
if (m_entry == entry) {
|
||||
m_entry = NULL;
|
||||
if (m_chrome) {
|
||||
fe_SetTextField(m_name, "");
|
||||
fe_SetTextField(m_location, "");
|
||||
fe_SetTextField(m_description, "");
|
||||
if (m_lastVisited) fe_SetString(m_lastVisited, XmNlabelString, " ");
|
||||
if (m_addedOn) fe_SetString(m_addedOn, XmNlabelString, " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
XFE_BookmarkPropDialog::getAndCleanText(Widget widget,
|
||||
Boolean new_lines_too_p)
|
||||
{
|
||||
char *str;
|
||||
|
||||
str = fe_GetTextField(widget);
|
||||
if (!str) {
|
||||
return NULL;
|
||||
}
|
||||
fe_forms_clean_text(m_context, INTL_DefaultWinCharSetID(NULL), str,
|
||||
new_lines_too_p);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
XP_Bool
|
||||
XFE_BookmarkPropDialog::commitChanges()
|
||||
{
|
||||
XFE_BookmarkView *view = (XFE_BookmarkView*)BM_GetFEData(m_context);
|
||||
char* ptr = 0;
|
||||
|
||||
if (!m_entry) return(True);
|
||||
ptr = getAndCleanText(m_name, True);
|
||||
if (!ptr) {
|
||||
return(False);
|
||||
}
|
||||
|
||||
// Have the view set the name so it can keep track
|
||||
// of the personal toolbar.
|
||||
if (view)
|
||||
view->setName(m_entry, ptr);
|
||||
XP_FREE(ptr);
|
||||
|
||||
ptr = getAndCleanText(m_location, True);
|
||||
if (!ptr) {
|
||||
return(False);
|
||||
}
|
||||
BM_SetAddress(m_context, m_entry, ptr);
|
||||
XP_FREE(ptr);
|
||||
|
||||
ptr = getAndCleanText(m_description, False);
|
||||
if (!ptr) {
|
||||
return(False);
|
||||
}
|
||||
BM_SetDescription(m_context, m_entry, ptr);
|
||||
XP_FREE(ptr);
|
||||
|
||||
return(True);
|
||||
}
|
||||
|
||||
93
mozilla/cmd/xfe/src/BookmarkPropDialog.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
BookmarkPropDialog.h -- class definitions for edit properties dialog
|
||||
Created: Stephen Lamm <slamm@netscape.com>, 10-Mar-97.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _xfe_bookmark_prop_dialog_h
|
||||
#define _xfe_bookmark_prop_dialog_h
|
||||
|
||||
#include "Component.h"
|
||||
#include "Dialog.h"
|
||||
#include "mozilla.h" /* for MWContext ! */
|
||||
|
||||
class XFE_BookmarkPropDialog : public XFE_Dialog
|
||||
{
|
||||
public:
|
||||
|
||||
// Constructors, Destructors
|
||||
|
||||
XFE_BookmarkPropDialog(MWContext *context, Widget parent);
|
||||
|
||||
virtual ~XFE_BookmarkPropDialog();
|
||||
|
||||
void editItem(BM_Entry *entry);
|
||||
void entryGoingAway(BM_Entry *entry);
|
||||
void selectAlias();
|
||||
void close();
|
||||
void ok();
|
||||
|
||||
XP_Bool commitChanges();
|
||||
|
||||
//virtual void show();
|
||||
|
||||
//virtual void hide();
|
||||
|
||||
static void selectalias_cb(Widget widget,
|
||||
XtPointer closure, XtPointer call_data);
|
||||
static void destroy_cb(Widget widget,
|
||||
XtPointer closure, XtPointer call_data);
|
||||
static void close_cb(Widget widget,
|
||||
XtPointer closure, XtPointer call_data);
|
||||
static void ok_cb(Widget widget,
|
||||
XtPointer closure, XtPointer call_data);
|
||||
|
||||
protected:
|
||||
|
||||
char *getAndCleanText(Widget widget, Boolean new_lines_too_p);
|
||||
|
||||
/* Parent class members
|
||||
Widget m_wParent; // parent widget
|
||||
Widget m_chrome; // dialog chrome - selection box
|
||||
Widget m_okButton;
|
||||
Widget m_cancelButton;
|
||||
Widget m_helpButton;
|
||||
Widget m_applyButton;
|
||||
*/
|
||||
|
||||
MWContext *m_context;
|
||||
|
||||
BM_Entry *m_entry;
|
||||
|
||||
Widget m_title;
|
||||
Widget m_nickname;
|
||||
Widget m_name;
|
||||
Widget m_location;
|
||||
Widget m_locationLabel;
|
||||
Widget m_description;
|
||||
Widget m_lastVisited;
|
||||
Widget m_lastVisitedLabel;
|
||||
Widget m_addedOn;
|
||||
Widget m_aliasLabel;
|
||||
Widget m_aliasButton;
|
||||
};
|
||||
|
||||
#endif /* _xfe_dialog_h */
|
||||
2067
mozilla/cmd/xfe/src/BookmarkView.cpp
Normal file
228
mozilla/cmd/xfe/src/BookmarkView.h
Normal file
@@ -0,0 +1,228 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
BookmarkView.h -- class definition for XFE_BookmarkView
|
||||
Created: Chris Toshok <toshok@netscape.com>, 7-Aug-96.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _xfe_bookmarkview_h
|
||||
#define _xfe_bookmarkview_h
|
||||
|
||||
#include "View.h"
|
||||
#include "Outliner.h"
|
||||
#include "Outlinable.h"
|
||||
#include "PopupMenu.h"
|
||||
#include "BookmarkPropDialog.h"
|
||||
#include "BookmarkWhatsNewDialog.h"
|
||||
#include "bkmks.h"
|
||||
|
||||
typedef struct BookmarkClipboard {
|
||||
void *block;
|
||||
int32 length;
|
||||
} BookmarkClipboard;
|
||||
|
||||
class XFE_BookmarkView : public XFE_View, public XFE_Outlinable
|
||||
{
|
||||
public:
|
||||
XFE_BookmarkView(XFE_Component *toplevel, Widget parent, XFE_View *parent_view, MWContext *context);
|
||||
|
||||
virtual ~XFE_BookmarkView();
|
||||
|
||||
// Methods we override from XFE_View
|
||||
virtual Boolean isCommandEnabled(CommandType cmd, void *calldata = NULL,
|
||||
XFE_CommandInfo* i = NULL);
|
||||
virtual void doCommand(CommandType cmd, void *calldata = NULL,
|
||||
XFE_CommandInfo* i = NULL);
|
||||
virtual Boolean handlesCommand(CommandType cmd, void *calldata = NULL,
|
||||
XFE_CommandInfo* i = NULL);
|
||||
virtual XP_Bool isCommandSelected(CommandType cmd, void *calldata,
|
||||
XFE_CommandInfo* info);
|
||||
virtual char *commandToString(CommandType cmd, void *calldata = NULL,
|
||||
XFE_CommandInfo* i = NULL);
|
||||
|
||||
// Our equivalent to the BMFE_* calls
|
||||
void refreshCells(int first = 1, int last = BM_LAST_CELL,
|
||||
XP_Bool now = TRUE);
|
||||
void gotoBookmark(const char *url);
|
||||
void scrollIntoView(BM_Entry *entry);
|
||||
void setClipContents(void *block, int32 length);
|
||||
void *getClipContents(int32 *length);
|
||||
void freeClipContents();
|
||||
void startWhatsChanged();
|
||||
void updateWhatsChanged(const char *url, int32 done, int32 total, const char *totaltime);
|
||||
void finishedWhatsChanged(int32 totalchecked, int32 numreached, int32 numchanged);
|
||||
void startBatch();
|
||||
void endBatch();
|
||||
void bookmarkMenuInvalid();
|
||||
|
||||
// Wrapper around BM_SetName() that handles personal toolbar folder
|
||||
void setName(BM_Entry *entry, char *name);
|
||||
|
||||
Boolean loadBookmarks(char *filename);
|
||||
Boolean copyBookmarksFile(char *dst, char *src);
|
||||
|
||||
// The Outlinable interface.
|
||||
virtual void *ConvFromIndex(int index);
|
||||
virtual int ConvToIndex(void *item);
|
||||
|
||||
virtual char *getColumnName(int column);
|
||||
|
||||
virtual char *getColumnHeaderText(int column);
|
||||
virtual fe_icon *getColumnHeaderIcon(int column);
|
||||
virtual EOutlinerTextStyle getColumnHeaderStyle(int column);
|
||||
virtual void *acquireLineData(int line);
|
||||
virtual void getTreeInfo(XP_Bool *expandable, XP_Bool *is_expanded,
|
||||
int *depth, OutlinerAncestorInfo **ancestor);
|
||||
virtual EOutlinerTextStyle getColumnStyle(int column);
|
||||
virtual char *getColumnText(int column);
|
||||
virtual fe_icon *getColumnIcon(int column);
|
||||
virtual void releaseLineData();
|
||||
|
||||
virtual void Buttonfunc(const OutlineButtonFuncData *data);
|
||||
virtual void Flippyfunc(const OutlineFlippyFuncData *data);
|
||||
|
||||
virtual XFE_Outliner *getOutliner();
|
||||
// Get tooltipString & docString;
|
||||
// returned string shall be freed by the callee
|
||||
// row < 0 indicates heading row; otherwise it is a content row
|
||||
// (starting from 0)
|
||||
//
|
||||
virtual char *getCellTipString(int /* row */, int /* column */) {return NULL;}
|
||||
virtual char *getCellDocString(int /* row */, int /* column */) {return NULL;}
|
||||
|
||||
// columns for the Outliner
|
||||
static const int OUTLINER_COLUMN_NAME;
|
||||
static const int OUTLINER_COLUMN_LOCATION;
|
||||
static const int OUTLINER_COLUMN_LASTVISITED;
|
||||
static const int OUTLINER_COLUMN_CREATEDON;
|
||||
|
||||
static const char *bookmarksChangedCallback; // the user has added/editted/deleted a bookmark entry.
|
||||
static const char *bookmarkDoubleClickedCallback; // the user has double clicked a bookmark entry.
|
||||
static const char *bookmarkClickedCallback; // the user has single clicked a bookmark entry.
|
||||
|
||||
// Open properties dialog
|
||||
void openBookmarksWindow();
|
||||
void closeBookmarksWindow();
|
||||
|
||||
// Edit an item in the properties dialog if it's open
|
||||
void editItem(BM_Entry *entry);
|
||||
void entryGoingAway(BM_Entry *entry);
|
||||
|
||||
void makeEditItemDialog();
|
||||
|
||||
#if defined(USE_MOTIF_DND)
|
||||
|
||||
/* motif drag and drop interface. */
|
||||
fe_icon_data *GetDragIconData(int row, int column);
|
||||
static fe_icon_data *getDragIconData(void *this_ptr,
|
||||
int row, int column);
|
||||
|
||||
void GetDragTargets(int row, int column, Atom **targets, int *num_targets);
|
||||
static void getDragTargets(void *this_ptr,
|
||||
int row, int col,
|
||||
Atom **targets, int *num_targets);
|
||||
|
||||
char *DragConvert(Atom atom);
|
||||
static char* dragConvert(void *this_ptr,
|
||||
Atom atom);
|
||||
|
||||
int ProcessTargets(int row, int col,
|
||||
Atom *targets,
|
||||
const char **data,
|
||||
int numItems);
|
||||
static int processTargets(void *this_ptr,
|
||||
int row, int col,
|
||||
Atom *targets,
|
||||
const char **data,
|
||||
int numItems);
|
||||
|
||||
/* no instance method needed for getDropTargets */
|
||||
static void getDropTargets(void *this_ptr,
|
||||
Atom **targets, int *num_targets);
|
||||
#endif /* USE_MOTIF_DND */
|
||||
|
||||
private:
|
||||
BM_Entry *m_entry; // needed by the outlinable interface methods.
|
||||
int m_entryDepth; // needed by the outlinable interface methods.
|
||||
OutlinerAncestorInfo *m_ancestorInfo; // needed by the outlinable interface methods.
|
||||
|
||||
XFE_Outliner *m_outliner; // the outliner object used to display everything.
|
||||
XFE_PopupMenu *m_popup;
|
||||
|
||||
XP_Bool m_sortDescending;
|
||||
CommandType m_lastSort;
|
||||
|
||||
BookmarkClipboard clip; // our clipboard.
|
||||
BM_Entry *m_editentry; // the entry currently being editted
|
||||
|
||||
XFE_BookmarkPropDialog *m_propertiesDialog;
|
||||
XFE_BookmarkWhatsNewDialog *m_whatsNewDialog;
|
||||
|
||||
// Use these to avoid multiple FE updates
|
||||
XP_Bool m_batchDepth;
|
||||
XP_Bool m_menuIsInvalid;
|
||||
|
||||
static MenuSpec open_popup_spec[];
|
||||
static MenuSpec new_popup_spec[];
|
||||
static MenuSpec set_popup_spec[];
|
||||
static MenuSpec saveas_popup_spec[];
|
||||
static MenuSpec cutcopy_popup_spec[];
|
||||
static MenuSpec copylink_popup_spec[];
|
||||
static MenuSpec paste_popup_spec[];
|
||||
static MenuSpec delete_popup_spec[];
|
||||
static MenuSpec makealias_popup_spec[];
|
||||
static MenuSpec properties_popup_spec[];
|
||||
|
||||
// Remove our reference to the dialog when it goes away
|
||||
static void properties_destroy_cb(Widget widget,
|
||||
XtPointer closure, XtPointer call_data);
|
||||
static void whats_new_destroy_cb(Widget widget,
|
||||
XtPointer closure, XtPointer call_data);
|
||||
|
||||
BM_CommandType commandToBMCmd(CommandType cmd);
|
||||
|
||||
#if !defined(USE_MOTIF_DND)
|
||||
|
||||
void dropfunc(Widget dropw, fe_dnd_Event type, fe_dnd_Source *source, XEvent *event);
|
||||
static void drop_func(Widget dropw, void *closure, fe_dnd_Event type,
|
||||
fe_dnd_Source *source, XEvent* event);
|
||||
#endif
|
||||
|
||||
void doPopup(XEvent *event);
|
||||
|
||||
// icons for use in the bookmark window.
|
||||
static fe_icon bookmark;
|
||||
static fe_icon mailBookmark;
|
||||
static fe_icon newsBookmark;
|
||||
static fe_icon changedBookmark;
|
||||
// static fe_icon unknownBookmark;
|
||||
static fe_icon closedFolder;
|
||||
static fe_icon openedFolder;
|
||||
static fe_icon closedPersonalFolder;
|
||||
static fe_icon openedPersonalFolder;
|
||||
static fe_icon closedFolderDest;
|
||||
static fe_icon openedFolderDest;
|
||||
static fe_icon closedFolderMenu;
|
||||
static fe_icon openedFolderMenu;
|
||||
static fe_icon closedFolderMenuDest;
|
||||
static fe_icon openedFolderMenuDest;
|
||||
};
|
||||
|
||||
#endif /* _xfe_bookmarkview_h */
|
||||
202
mozilla/cmd/xfe/src/BookmarkWhatsNewDialog.cpp
Normal file
@@ -0,0 +1,202 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
BookmarkWhatsNewDialog.cpp -- dialog for checking "What's New".
|
||||
Created: Stephen Lamm <slamm@netscape.com>, 28-May-97.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "BookmarkWhatsNewDialog.h"
|
||||
#include "bkmks.h"
|
||||
#include "xfe.h"
|
||||
#include "xpgetstr.h"
|
||||
|
||||
extern int XFE_LOOK_FOR_DOCUMENTS_THAT_HAVE_CHANGED_ON;
|
||||
extern int XFE_ESTIMATED_TIME_REMAINING_CHECKED;
|
||||
extern int XFE_ESTIMATED_TIME_REMAINING_CHECKING;
|
||||
extern int XFE_DONE_CHECKING_ETC;
|
||||
|
||||
XFE_BookmarkWhatsNewDialog::XFE_BookmarkWhatsNewDialog(MWContext *context, Widget parent)
|
||||
: XFE_Dialog(parent, "bookmarksWhatsChanged",
|
||||
TRUE, // ok
|
||||
TRUE, // cancel
|
||||
FALSE, // help
|
||||
TRUE, // apply
|
||||
TRUE, // Separator
|
||||
FALSE // Modal
|
||||
)
|
||||
{
|
||||
m_context = context;
|
||||
|
||||
fe_UnmanageChild_safe (m_okButton);
|
||||
|
||||
XtVaSetValues(m_chrome, XmNchildPlacement, XmPLACE_BELOW_SELECTION, NULL);
|
||||
|
||||
m_text = XmSelectionBoxGetChild (m_chrome, XmDIALOG_SELECTION_LABEL);
|
||||
|
||||
XtManageChild(m_text);
|
||||
|
||||
XtAddCallback(m_chrome, XmNdestroyCallback, destroy_cb, this);
|
||||
XtAddCallback(m_chrome, XmNcancelCallback, close_cb, this);
|
||||
XtAddCallback(m_chrome, XmNapplyCallback, apply_cb, this);
|
||||
XtAddCallback(m_chrome, XmNokCallback, ok_cb, this);
|
||||
|
||||
m_radioBox =
|
||||
XmVaCreateSimpleRadioBox(m_chrome, "radiobox", 0, NULL,
|
||||
XmVaRADIOBUTTON, NULL, NULL, NULL, NULL,
|
||||
XmVaRADIOBUTTON, NULL, NULL, NULL, NULL,
|
||||
NULL);
|
||||
|
||||
int numKids;
|
||||
Widget* kids;
|
||||
|
||||
XtVaGetValues(m_radioBox, XmNnumChildren, &numKids, XmNchildren, &kids, 0);
|
||||
XP_ASSERT(numKids == 2);
|
||||
|
||||
m_doAll = kids[0];
|
||||
m_doSelected = kids[1];
|
||||
|
||||
XtManageChildren(kids, numKids);
|
||||
|
||||
XtManageChild(m_radioBox);
|
||||
|
||||
XmString str = XmStringCreate( XP_GetString( XFE_LOOK_FOR_DOCUMENTS_THAT_HAVE_CHANGED_ON ),
|
||||
XmFONTLIST_DEFAULT_TAG);
|
||||
XtVaSetValues(m_text, XmNlabelString, str, NULL);
|
||||
XmStringFree(str);
|
||||
|
||||
fe_HackDialogTranslations (m_chrome);
|
||||
}
|
||||
|
||||
XFE_BookmarkWhatsNewDialog::~XFE_BookmarkWhatsNewDialog()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkWhatsNewDialog::destroy_cb(Widget /*widget*/,
|
||||
XtPointer closure, XtPointer /*call_data*/)
|
||||
{
|
||||
XFE_BookmarkWhatsNewDialog* obj = (XFE_BookmarkWhatsNewDialog *)closure;
|
||||
|
||||
obj->close();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
XFE_BookmarkWhatsNewDialog::close()
|
||||
{
|
||||
BM_CancelWhatsChanged(m_context);
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkWhatsNewDialog::close_cb(Widget /*widget*/,
|
||||
XtPointer closure, XtPointer /*call_data*/)
|
||||
{
|
||||
XFE_BookmarkWhatsNewDialog* obj = (XFE_BookmarkWhatsNewDialog *)closure;
|
||||
|
||||
XtDestroyWidget(obj->getBaseWidget());
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkWhatsNewDialog::apply()
|
||||
{
|
||||
Boolean doselected = FALSE;
|
||||
XtVaGetValues(m_doSelected, XmNset, &doselected, NULL);
|
||||
BM_StartWhatsChanged(m_context, doselected);
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkWhatsNewDialog::apply_cb(Widget /*widget*/,
|
||||
XtPointer closure, XtPointer /*call_data*/)
|
||||
{
|
||||
XFE_BookmarkWhatsNewDialog* obj = (XFE_BookmarkWhatsNewDialog *)closure;
|
||||
|
||||
obj->apply();
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkWhatsNewDialog::ok()
|
||||
{
|
||||
; // nothing more to do
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkWhatsNewDialog::ok_cb(Widget /*widget*/,
|
||||
XtPointer closure, XtPointer /*call_data*/)
|
||||
{
|
||||
XFE_BookmarkWhatsNewDialog* obj = (XFE_BookmarkWhatsNewDialog *)closure;
|
||||
|
||||
obj->ok();
|
||||
|
||||
XtDestroyWidget(obj->getBaseWidget());
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkWhatsNewDialog::updateWhatsChanged(const char* url,
|
||||
int32 done, int32 total,
|
||||
const char* totaltime)
|
||||
{
|
||||
char buf[1024];
|
||||
XmString str;
|
||||
|
||||
if (!m_chrome) return;
|
||||
|
||||
if (m_radioBox) {
|
||||
fe_UnmanageChild_safe(m_radioBox);
|
||||
fe_UnmanageChild_safe(m_applyButton);
|
||||
m_radioBox = NULL;
|
||||
}
|
||||
|
||||
if ( url )
|
||||
PR_snprintf(buf, sizeof(buf),
|
||||
XP_GetString( XFE_ESTIMATED_TIME_REMAINING_CHECKED ),
|
||||
url,
|
||||
total - done,
|
||||
total > 0 ? done * 100 / total : 0,
|
||||
totaltime);
|
||||
else
|
||||
PR_snprintf(buf, sizeof(buf),
|
||||
XP_GetString( XFE_ESTIMATED_TIME_REMAINING_CHECKING ),
|
||||
total - done,
|
||||
total > 0 ? done * 100 / total : 0,
|
||||
totaltime);
|
||||
|
||||
str = XmStringCreateLtoR(buf, XmFONTLIST_DEFAULT_TAG);
|
||||
XtVaSetValues(m_text, XmNlabelString, str, NULL);
|
||||
XmStringFree(str);
|
||||
}
|
||||
|
||||
void
|
||||
XFE_BookmarkWhatsNewDialog::finishedWhatsChanged(int32 totalchecked,
|
||||
int32 numreached,
|
||||
int32 numchanged)
|
||||
{
|
||||
char buf[1024];
|
||||
XmString str;
|
||||
fe_UnmanageChild_safe(m_radioBox);
|
||||
fe_UnmanageChild_safe(m_cancelButton);
|
||||
XtManageChild(m_okButton);
|
||||
PR_snprintf(buf, sizeof(buf), XP_GetString( XFE_DONE_CHECKING_ETC ),
|
||||
totalchecked, numreached, numchanged);
|
||||
|
||||
str = XmStringCreateLtoR(buf, XmFONTLIST_DEFAULT_TAG);
|
||||
XtVaSetValues(m_text, XmNlabelString, str, NULL);
|
||||
XmStringFree(str);
|
||||
}
|
||||
62
mozilla/cmd/xfe/src/BookmarkWhatsNewDialog.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
BookmarkWhatsNewDialog.h -- dialog for checking "What's New".
|
||||
Created: Stephen Lamm <slamm@netscape.com>, 28-May-97.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _xfe_bookmarkwhatsnewdialog_h
|
||||
#define _xfe_bookmarkwhatsnewdialog_h
|
||||
|
||||
#include "Dialog.h"
|
||||
#include "bkmks.h"
|
||||
|
||||
class XFE_BookmarkWhatsNewDialog : public XFE_Dialog
|
||||
{
|
||||
public:
|
||||
XFE_BookmarkWhatsNewDialog(MWContext *context, Widget parent);
|
||||
|
||||
virtual ~XFE_BookmarkWhatsNewDialog();
|
||||
|
||||
void updateWhatsChanged(const char *url, int32 done, int32 total, const char *totaltime);
|
||||
void finishedWhatsChanged(int32 totalchecked, int32 numreached, int32 numchanged);
|
||||
|
||||
private:
|
||||
void close();
|
||||
void apply();
|
||||
void ok();
|
||||
|
||||
static void destroy_cb(Widget widget,
|
||||
XtPointer closure, XtPointer call_data);
|
||||
static void close_cb(Widget, XtPointer, XtPointer);
|
||||
static void apply_cb(Widget, XtPointer, XtPointer);
|
||||
static void ok_cb(Widget, XtPointer, XtPointer);
|
||||
|
||||
MWContext *m_context;
|
||||
|
||||
Widget m_text;
|
||||
|
||||
Widget m_radioBox;
|
||||
Widget m_doAll;
|
||||
Widget m_doSelected;
|
||||
};
|
||||
|
||||
|
||||
#endif /* xfe_bookmarkwhatsnewdialog_h */
|
||||
184
mozilla/cmd/xfe/src/HistoryFrame.cpp
Normal file
@@ -0,0 +1,184 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
HistoryFrame.cpp -- History window stuff
|
||||
Created: Stephen Lamm <slamm@netscape.com>, 24-Feb-96.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "HistoryFrame.h"
|
||||
#include "HistoryView.h"
|
||||
#include "xpassert.h"
|
||||
#include "xfe2_extern.h"
|
||||
#include "abdefn.h" // for kMaxFullNameLength
|
||||
#include "xpgetstr.h" // for XP_GetString()
|
||||
#include "Dashboard.h"
|
||||
|
||||
extern int XFE_HISTORY_FRAME_TITLE;
|
||||
|
||||
static XFE_HistoryFrame *theFrame = NULL;
|
||||
|
||||
// Basically, anything with "" around it hasn't been wired-up/implemented.
|
||||
MenuSpec XFE_HistoryFrame::file_menu_spec[] = {
|
||||
{ "newSubmenu", CASCADEBUTTON,
|
||||
(MenuSpec*)&XFE_Frame::new_menu_spec },
|
||||
MENU_SEPARATOR,
|
||||
{ xfeCmdSaveAs, PUSHBUTTON },
|
||||
MENU_SEPARATOR,
|
||||
{ xfeCmdOpenSelected, PUSHBUTTON },
|
||||
{ xfeCmdAddBookmark, PUSHBUTTON },
|
||||
{ xfeCmdAddToToolbar, PUSHBUTTON },
|
||||
//{ xfeCmdCreateShortcut, PUSHBUTTON }, // Create desktop shortcut
|
||||
//MENU_SEPARATOR,
|
||||
//{ xfeCmdPrintSetup, PUSHBUTTON },
|
||||
//{ xfeCmdPrint, PUSHBUTTON },
|
||||
MENU_SEPARATOR,
|
||||
{ xfeCmdClose, PUSHBUTTON },
|
||||
{ xfeCmdExit, PUSHBUTTON },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
MenuSpec XFE_HistoryFrame::edit_menu_spec[] = {
|
||||
{ xfeCmdUndo, PUSHBUTTON },
|
||||
{ xfeCmdRedo, PUSHBUTTON },
|
||||
MENU_SEPARATOR,
|
||||
{ xfeCmdCut, PUSHBUTTON },
|
||||
{ xfeCmdCopy, PUSHBUTTON },
|
||||
{ xfeCmdDelete, PUSHBUTTON },
|
||||
{ xfeCmdSelectAll, PUSHBUTTON },
|
||||
MENU_SEPARATOR,
|
||||
//{ xfeCmdSearch, PUSHBUTTON }, // We should have this, but it isn't ready
|
||||
#ifdef MOZ_MAIL_NEWS
|
||||
{ xfeCmdSearchAddress, PUSHBUTTON },
|
||||
MENU_SEPARATOR,
|
||||
#endif
|
||||
{ xfeCmdEditPreferences, PUSHBUTTON },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
MenuSpec XFE_HistoryFrame::view_menu_spec[] = {
|
||||
{ xfeCmdSortByTitle, TOGGLEBUTTON, NULL, "sortByRadioGroup",
|
||||
False, (void*)eHSC_TITLE },
|
||||
{ xfeCmdSortByLocation, TOGGLEBUTTON, NULL, "sortByRadioGroup",
|
||||
False, (void*)eHSC_LOCATION },
|
||||
{ xfeCmdSortByDateFirstVisited, TOGGLEBUTTON, NULL, "sortByRadioGroup",
|
||||
False, (void*)eHSC_FIRSTVISIT },
|
||||
{ xfeCmdSortByDateLastVisited, TOGGLEBUTTON, NULL, "sortByRadioGroup",
|
||||
False, (void*)eHSC_LASTVISIT },
|
||||
{ xfeCmdSortByExpirationDate, TOGGLEBUTTON, NULL, "sortByRadioGroup",
|
||||
False, (void*)eHSC_EXPIRES },
|
||||
{ xfeCmdSortByVisitCount, TOGGLEBUTTON, NULL, "sortByRadioGroup",
|
||||
False, (void*)eHSC_VISITCOUNT },
|
||||
MENU_SEPARATOR,
|
||||
{ xfeCmdSortAscending, TOGGLEBUTTON, NULL, "ascendDescendRadioGroup",
|
||||
False },
|
||||
{ xfeCmdSortDescending, TOGGLEBUTTON, NULL, "ascendDescendRadioGroup",
|
||||
False },
|
||||
//MENU_SEPARATOR,
|
||||
//{ xfeCmdMoreOptions, PUSHBUTTON },
|
||||
//{ xfeCmdFewerOptions, PUSHBUTTON },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
MenuSpec XFE_HistoryFrame::menu_bar_spec[] = {
|
||||
{ xfeMenuFile, CASCADEBUTTON, file_menu_spec },
|
||||
{ xfeMenuEdit, CASCADEBUTTON, edit_menu_spec },
|
||||
{ xfeMenuView, CASCADEBUTTON, view_menu_spec },
|
||||
{ xfeMenuWindow, CASCADEBUTTON, XFE_Frame::window_menu_spec },
|
||||
{ "bookmarksSubmenu", CASCADEBUTTON, XFE_Frame::bookmark_submenu_spec },
|
||||
{ xfeMenuHelp, CASCADEBUTTON, XFE_Frame::help_menu_spec },
|
||||
{ NULL }
|
||||
};
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
XFE_HistoryFrame::XFE_HistoryFrame(Widget toplevel, XFE_Frame *parent_frame, Chrome *chromespec)
|
||||
: XFE_Frame("history", toplevel, parent_frame,
|
||||
FRAME_HISTORY, chromespec, False, True, False, True, False)
|
||||
{
|
||||
// create the History view
|
||||
XFE_HistoryView *view = new XFE_HistoryView(this,
|
||||
getChromeParent(),
|
||||
NULL,
|
||||
m_context);
|
||||
|
||||
setView(view);
|
||||
|
||||
setMenubar(menu_bar_spec);
|
||||
|
||||
//
|
||||
// Make the bookmark frame title more reasonable
|
||||
//
|
||||
char title[kMaxFullNameLength+64];
|
||||
|
||||
PR_snprintf(title,
|
||||
sizeof(title),
|
||||
XP_GetString(XFE_HISTORY_FRAME_TITLE),
|
||||
FE_UsersFullName());
|
||||
|
||||
setTitle(title);
|
||||
|
||||
view->show();
|
||||
|
||||
m_dashboard->setShowStatusBar(True);
|
||||
m_dashboard->setShowProgressBar(True);
|
||||
|
||||
resize(600,580); //XXX Default size for now
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
XFE_HistoryFrame::~XFE_HistoryFrame()
|
||||
{
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
XFE_HistoryFrame::showHistory(Widget toplevel, XFE_Frame *parent_frame, Chrome *chromespec)
|
||||
{
|
||||
fe_showHistory(toplevel, parent_frame, chromespec);
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
XP_Bool
|
||||
XFE_HistoryFrame::isCommandEnabled(CommandType cmd,
|
||||
void *calldata, XFE_CommandInfo*)
|
||||
{
|
||||
if (cmd == xfeCmdClose)
|
||||
return True;
|
||||
else
|
||||
return XFE_Frame::isCommandEnabled(cmd, calldata);
|
||||
}
|
||||
|
||||
extern "C" MWContext*
|
||||
fe_showHistory(Widget toplevel, XFE_Frame *parent_frame, Chrome *chromespec)
|
||||
{
|
||||
/* Check to see if we have access to the global history database. */
|
||||
if (fe_globalData.all_databases_locked)
|
||||
return NULL;
|
||||
|
||||
fe_createHistory(toplevel, parent_frame, chromespec);
|
||||
|
||||
theFrame->show();
|
||||
|
||||
return theFrame->getContext();
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
fe_createHistory(Widget toplevel,
|
||||
XFE_Frame *parent_frame,
|
||||
Chrome *chromespec)
|
||||
{
|
||||
if (theFrame == NULL)
|
||||
theFrame = new XFE_HistoryFrame(toplevel, parent_frame, chromespec);
|
||||
}
|
||||
50
mozilla/cmd/xfe/src/HistoryFrame.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
HistoryFrame.h -- class definitions for history frames
|
||||
Created: Stephen Lamm <slamm@netscape.com>, 24-Feb-96.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _xfe_historyframe_h
|
||||
#define _xfe_historyframe_h
|
||||
|
||||
#include "Frame.h"
|
||||
#include "xp_core.h"
|
||||
#include <Xm/Xm.h>
|
||||
|
||||
class XFE_HistoryFrame : public XFE_Frame
|
||||
{
|
||||
public:
|
||||
XFE_HistoryFrame(Widget toplevel, XFE_Frame *parent_frame, Chrome *chromespec);
|
||||
virtual ~XFE_HistoryFrame();
|
||||
|
||||
static void showHistory(Widget toplevel, XFE_Frame *parent_frame, Chrome *chromespec);
|
||||
|
||||
// To allow window close (we need a more graceful way of doing this)
|
||||
virtual XP_Bool isCommandEnabled(CommandType cmd, void *calldata = NULL,
|
||||
XFE_CommandInfo* = NULL);
|
||||
private:
|
||||
static MenuSpec menu_bar_spec[];
|
||||
static MenuSpec file_menu_spec[];
|
||||
static MenuSpec edit_menu_spec[];
|
||||
static MenuSpec view_menu_spec[];
|
||||
};
|
||||
|
||||
#endif /* _xfe_historyframe_h */
|
||||
1238
mozilla/cmd/xfe/src/HistoryView.cpp
Normal file
189
mozilla/cmd/xfe/src/HistoryView.h
Normal file
@@ -0,0 +1,189 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
HistoryView.h -- class definition for HistoryView
|
||||
Created: Stephen Lamm <slamm@netscape.com>, 24-Feb-96.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _xfe_historyview_h
|
||||
#define _xfe_historyview_h
|
||||
|
||||
#include "View.h"
|
||||
#include "Outliner.h"
|
||||
#include "Outlinable.h"
|
||||
|
||||
#include "glhist.h"
|
||||
#include "xp.h"
|
||||
|
||||
enum enHistSortCol
|
||||
{
|
||||
eHSC_INVALID = -1,
|
||||
eHSC_TITLE,
|
||||
eHSC_LOCATION,
|
||||
eHSC_FIRSTVISIT,
|
||||
eHSC_LASTVISIT,
|
||||
eHSC_EXPIRES,
|
||||
eHSC_VISITCOUNT
|
||||
};
|
||||
|
||||
typedef struct HistoryClipboard {
|
||||
void *block;
|
||||
int32 length;
|
||||
} HistoryClipboard;
|
||||
|
||||
class XFE_HistoryView : public XFE_View, public XFE_Outlinable
|
||||
{
|
||||
public:
|
||||
XFE_HistoryView(XFE_Component *toplevel, Widget parent, XFE_View *parent_view, MWContext *context);
|
||||
|
||||
~XFE_HistoryView();
|
||||
|
||||
// Methods we override from XFE_View
|
||||
virtual Boolean isCommandEnabled(CommandType cmd, void *calldata = NULL,
|
||||
XFE_CommandInfo* i = NULL);
|
||||
virtual void doCommand(CommandType cmd, void *calldata = NULL,
|
||||
XFE_CommandInfo* i = NULL);
|
||||
virtual Boolean handlesCommand(CommandType cmd, void *calldata = NULL,
|
||||
XFE_CommandInfo* i = NULL);
|
||||
virtual char *commandToString(CommandType cmd, void *calldata = NULL,
|
||||
XFE_CommandInfo* i = NULL);
|
||||
virtual XP_Bool isCommandSelected(CommandType cmd,
|
||||
void *calldata = NULL,
|
||||
XFE_CommandInfo* info = NULL);
|
||||
|
||||
// Our equivalent to the backend calls
|
||||
void refreshCells(int first, int last, XP_Bool now);
|
||||
void scrollIntoView(gh_HistEntry *entry);
|
||||
void setClipContents(void *block, int32 length);
|
||||
void *getClipContents(int32 *length);
|
||||
void freeClipContents();
|
||||
// void openHistoryWindow();
|
||||
|
||||
// public access to history list
|
||||
virtual gh_HistEntry *getEntry(int);
|
||||
|
||||
//Boolean loadHistory(char *filename);
|
||||
|
||||
// The Outlinable interface.
|
||||
virtual void *ConvFromIndex(int index);
|
||||
virtual int ConvToIndex(void *item);
|
||||
|
||||
virtual char *getColumnName(int column);
|
||||
|
||||
virtual char *getColumnHeaderText(int column);
|
||||
virtual fe_icon *getColumnHeaderIcon(int column);
|
||||
virtual EOutlinerTextStyle getColumnHeaderStyle(int column);
|
||||
virtual void *acquireLineData(int line);
|
||||
virtual void getTreeInfo(XP_Bool *expandable, XP_Bool *is_expanded,
|
||||
int *depth, OutlinerAncestorInfo **ancestor);
|
||||
virtual EOutlinerTextStyle getColumnStyle(int column);
|
||||
virtual char *getColumnText(int column);
|
||||
virtual fe_icon *getColumnIcon(int column);
|
||||
virtual void releaseLineData();
|
||||
|
||||
virtual void Buttonfunc(const OutlineButtonFuncData *data);
|
||||
virtual void Flippyfunc(const OutlineFlippyFuncData *data);
|
||||
|
||||
virtual XFE_Outliner *getOutliner();
|
||||
// Get tooltipString & docString;
|
||||
// returned string shall be freed by the callee
|
||||
// row < 0 indicates heading row; otherwise it is a content row
|
||||
// (starting from 0)
|
||||
//
|
||||
virtual char *getCellTipString(int /* row */, int /* column */) {return NULL;}
|
||||
virtual char *getCellDocString(int /* row */, int /* column */) {return NULL;}
|
||||
|
||||
// columns for the Outliner
|
||||
static const int OUTLINER_COLUMN_TITLE;
|
||||
static const int OUTLINER_COLUMN_LOCATION;
|
||||
static const int OUTLINER_COLUMN_FIRSTVISITED;
|
||||
static const int OUTLINER_COLUMN_LASTVISITED;
|
||||
static const int OUTLINER_COLUMN_EXPIRES;
|
||||
static const int OUTLINER_COLUMN_VISITCOUNT;
|
||||
|
||||
#if defined(USE_MOTIF_DND)
|
||||
|
||||
/* motif drag and drop interface. */
|
||||
fe_icon_data *GetDragIconData(int row, int column);
|
||||
static fe_icon_data *getDragIconData(void *this_ptr,
|
||||
int row, int column);
|
||||
|
||||
void GetDragTargets(int row, int column, Atom **targets, int *num_targets);
|
||||
static void getDragTargets(void *this_ptr,
|
||||
int row, int col,
|
||||
Atom **targets, int *num_targets);
|
||||
|
||||
char *DragConvert(Atom atom);
|
||||
static char* dragConvert(void *this_ptr,
|
||||
Atom atom);
|
||||
#endif /* USE_MOTIF_DND */
|
||||
|
||||
static const char *historysChangedCallback; // the user has added/editted/deleted a history entry.
|
||||
static const char *historyDoubleClickedCallback; // the user has double clicked a history entry.
|
||||
static const char *historyClickedCallback; // the user has single clicked a history entry.
|
||||
|
||||
private:
|
||||
GHHANDLE m_histCursor;
|
||||
int m_totalLines;
|
||||
|
||||
XP_Bool m_dirty;
|
||||
|
||||
enHistSortCol m_sortBy;
|
||||
XP_Bool m_sortDescending;
|
||||
gh_Filter* m_filter;
|
||||
|
||||
// needed by the outlinable interface methods.
|
||||
OutlinerAncestorInfo *m_ancestorInfo;
|
||||
gh_HistEntry *m_entry;
|
||||
|
||||
#if defined(USE_MOTIF_DND)
|
||||
/* the entry that we're currently dragging. */
|
||||
gh_HistEntry *m_dragentry;
|
||||
#endif /* USE_MOTIF_DND */
|
||||
|
||||
XFE_Outliner *m_outliner;
|
||||
|
||||
XP_List *m_selectList;
|
||||
|
||||
// icons for use in the history window.
|
||||
static fe_icon historyIcon;
|
||||
|
||||
void dropfunc(Widget dropw, fe_dnd_Event type,
|
||||
fe_dnd_Source *source, XEvent *event);
|
||||
static void drop_func(Widget dropw, void *closure, fe_dnd_Event type,
|
||||
fe_dnd_Source *source, XEvent* event);
|
||||
|
||||
gh_HistEntry *getSelection();
|
||||
|
||||
void openSelected();
|
||||
void reflectSelected();
|
||||
void saveSelected();
|
||||
void restoreSelected();
|
||||
|
||||
int notify(gh_NotifyMsg *msg);
|
||||
static int notify_cb(gh_NotifyMsg *msg);
|
||||
|
||||
void resort(enHistSortCol sortBy, XP_Bool sortDescending);
|
||||
|
||||
void refresh();
|
||||
static void refresh_cb(XtPointer closure, XtIntervalId *id);
|
||||
};
|
||||
|
||||
#endif /* _xfe_historyview_h */
|
||||
514
mozilla/cmd/xfe/src/TreeView.cpp
Normal file
@@ -0,0 +1,514 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
TreeView.cpp -- class definition for XFE_TreeView
|
||||
Created: spence murray <spence@netscape.com>, 3-Nov-97.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "TreeView.h"
|
||||
#include "Outlinable.h"
|
||||
#include "BookmarkView.h"
|
||||
#include "AddrBookView.h"
|
||||
#include "HistoryView.h"
|
||||
#include "ViewGlue.h"
|
||||
#include "Frame.h"
|
||||
#include "mozilla.h"
|
||||
|
||||
#define TREE_OUTLINER_GEOMETRY_PREF "tree.outliner_geometry"
|
||||
|
||||
extern "C" MWContext *fe_WidgetToMWContext (Widget);
|
||||
|
||||
// Sanity check on the context. Throughout the progress stuff below,
|
||||
// the context (and fe_data) needs to be checked for validity before
|
||||
// dereferencing the members.
|
||||
#define CHECK_CONTEXT_AND_DATA(c) \
|
||||
((c) && CONTEXT_DATA(c) && !CONTEXT_DATA(context)->being_destroyed)
|
||||
|
||||
static XFE_Frame *
|
||||
fe_frameFromMWContext(MWContext *context)
|
||||
{
|
||||
XFE_Frame * frame = NULL;
|
||||
|
||||
// Sanity check for possible invocation of this function from a frame
|
||||
// that was just destroyed (or is being destroyed)
|
||||
if (!CHECK_CONTEXT_AND_DATA(context))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Try to use context's frame
|
||||
frame = ViewGlue_getFrame(XP_GetNonGridContext(context));
|
||||
|
||||
// Try to use the active frame
|
||||
// if (!frame)
|
||||
// {
|
||||
// frame = XFE_Frame::getActiveFrame();
|
||||
// }
|
||||
|
||||
// Make sure the frame is alive
|
||||
if (frame && !frame->isAlive())
|
||||
{
|
||||
frame = NULL;
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
XFE_TreeView::XFE_TreeView (const char *name,
|
||||
Widget parent,
|
||||
int tree_type,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
#ifdef DEBUG_spence
|
||||
printf ("XFE_TreeView: %s\n", name);
|
||||
#endif
|
||||
|
||||
// get the toplevel
|
||||
MWContext *context = fe_WidgetToMWContext (parent);
|
||||
XFE_Component *toplevel = fe_frameFromMWContext (context);
|
||||
|
||||
/* empty tree */
|
||||
if (tree_type == 0)
|
||||
{
|
||||
int i, n, size;
|
||||
XmLTreeRowDefinition *rows;
|
||||
static struct
|
||||
{
|
||||
Boolean expands;
|
||||
int level;
|
||||
char *string;
|
||||
} data[] =
|
||||
{
|
||||
{ True, 0, "Root" },
|
||||
{ True, 1, "Level 1 Parent" },
|
||||
{ False, 2, "1st Child of Level 1 Parent" },
|
||||
{ False, 2, "2nd Child of Level 1 Parent" },
|
||||
{ True, 2, "Level 2 Parent" },
|
||||
{ False, 3, "Child of Level 2 Parent" },
|
||||
{ True, 1, "Level 1 Parent" },
|
||||
{ False, 2, "Child of Level 1 Parent" },
|
||||
};
|
||||
|
||||
#ifdef DEBUG_spence
|
||||
printf ("empty tree\n");
|
||||
#endif
|
||||
|
||||
// create the tree
|
||||
m_tree = XtVaCreateManagedWidget("tree",
|
||||
xmlTreeWidgetClass, parent,
|
||||
XmNvisibleRows, 10,
|
||||
NULL);
|
||||
XtVaSetValues(m_tree,
|
||||
XmNcellDefaults, True,
|
||||
NULL);
|
||||
|
||||
/* Create a TreeRowDefinition array from the data array */
|
||||
/* and add rows to the Tree */
|
||||
n = 8;
|
||||
size = sizeof(XmLTreeRowDefinition) * n;
|
||||
rows = (XmLTreeRowDefinition *)malloc(size);
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
rows[i].level = data[i].level;
|
||||
rows[i].expands = data[i].expands;
|
||||
rows[i].isExpanded = True;
|
||||
rows[i].pixmap = XmUNSPECIFIED_PIXMAP;
|
||||
rows[i].pixmask = XmUNSPECIFIED_PIXMAP;
|
||||
rows[i].string = XmStringCreateSimple(data[i].string);
|
||||
}
|
||||
XmLTreeAddRows(m_tree, rows, n, -1);
|
||||
|
||||
/* Free the TreeRowDefintion array (and XmStrings) we created above */
|
||||
for (i = 0; i < n; i++)
|
||||
XmStringFree(rows[i].string);
|
||||
free((char *)rows);
|
||||
|
||||
#if 0
|
||||
// Save vertical scroller for keyboard accelerators
|
||||
CONTEXT_DATA(context)->vscroll = m_outliner->getScroller();
|
||||
m_outliner->show();
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_spence
|
||||
printf ("width = %d, height = %d\n", width, height);
|
||||
#endif
|
||||
|
||||
XtVaSetValues (m_tree, XmNwidth, width, XmNheight, height, NULL);
|
||||
|
||||
// load rdf database
|
||||
getRDFDB();
|
||||
|
||||
} else if (tree_type == 1) {
|
||||
#ifdef DEBUG_spence
|
||||
printf ("bookmark tree\n");
|
||||
#endif
|
||||
// bookmark tree
|
||||
// create the bookmark view
|
||||
XFE_BookmarkView *view = new XFE_BookmarkView(toplevel,
|
||||
parent,
|
||||
NULL,
|
||||
context);
|
||||
|
||||
XtVaSetValues(view->getBaseWidget(),
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
|
||||
view->show ();
|
||||
m_outliner = view->getOutliner ();
|
||||
} else if (tree_type == 2) {
|
||||
#ifdef DEBUG_spence
|
||||
printf ("addressbook tree\n");
|
||||
#endif
|
||||
// create the addressbook view;
|
||||
// import from XFE_BookmarkFrame::XFE_BookmarkFrame
|
||||
XFE_AddrBookView *view = new XFE_AddrBookView(toplevel,
|
||||
parent,
|
||||
NULL,
|
||||
context);
|
||||
} else if (tree_type == 3) {
|
||||
#ifdef DEBUG_spence
|
||||
printf ("history tree\n");
|
||||
#endif
|
||||
// create the History view
|
||||
XFE_HistoryView *view = new XFE_HistoryView(toplevel, parent, NULL, context);
|
||||
}
|
||||
|
||||
if (m_tree == NULL && m_outliner == NULL)
|
||||
{
|
||||
#ifdef DEBUG_spence
|
||||
printf ("XFE_TreeView: outliner create failed!\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
XFE_TreeView::~XFE_TreeView()
|
||||
{
|
||||
/* nothing to do here */
|
||||
}
|
||||
|
||||
void
|
||||
XFE_TreeView::getRDFDB()
|
||||
{
|
||||
HT_Notification ns;
|
||||
RDF_Resources std;
|
||||
|
||||
#ifdef DEBUG_spence
|
||||
printf ("getRDFDB:\n");
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
ns = (HT_Notification) XP_ALLOC (sizeof (HT_NotificationStruct));
|
||||
if (ns == NULL)
|
||||
{
|
||||
printf ("couldn't allocate NotificationStruct\n");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
ns = new HT_NotificationStruct;
|
||||
ns->notifyProc = (HT_NotificationProc) xfe_handleRDFNotify;
|
||||
ns->data = this;
|
||||
|
||||
#if 0
|
||||
std = RDF_StdVocab();
|
||||
#endif
|
||||
|
||||
// now create the HT_View - the backend representation of our tree
|
||||
m_htPane = HT_NewPane (ns);
|
||||
m_htView = HT_GetNthView (m_htPane, 0);
|
||||
// m_htView = HT_NewView (std->RDF_Top, m_htPane);
|
||||
|
||||
// now populate the tree
|
||||
drawTree ();
|
||||
}
|
||||
|
||||
void
|
||||
XFE_TreeView::handleRDFNotify (HT_Notification ns,
|
||||
HT_Resource node,
|
||||
HT_Event event)
|
||||
{
|
||||
#ifdef DEBUG_spence
|
||||
printf ("handleRDFNotify\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
XFE_TreeView::drawTree ()
|
||||
{
|
||||
HT_Pane pane;
|
||||
// fe_Data *feData = (fe_Data *) HT_GetViewFEData (m_htView);
|
||||
int count = HT_GetItemListCount (m_htView);
|
||||
int n = 0;
|
||||
|
||||
#ifdef DEBUG_spence
|
||||
printf ("drawTree\n");
|
||||
#endif
|
||||
|
||||
while (n < count) {
|
||||
HT_Resource node = HT_GetNthItem (m_htView, n);
|
||||
// add element to tree widget
|
||||
drawNode (node);
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
XFE_TreeView::drawNode (HT_Resource node)
|
||||
{
|
||||
HT_Cursor cursor;
|
||||
PRBool isContainer, isOpen, isSelected;
|
||||
uint16 colNum, depth;
|
||||
uint32 colWidth, colTokenType;
|
||||
void *data, *colToken;
|
||||
struct tm *time;
|
||||
time_t dateVal;
|
||||
char buffer [128];
|
||||
|
||||
if (isContainer = HT_IsContainer(node))
|
||||
{
|
||||
isOpen = HT_IsContainerOpen(node);
|
||||
// draw the node
|
||||
#ifdef DEBUG_spence
|
||||
printf ("node draw\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
if ((cursor = HT_NewColumnCursor(HT_GetView(node))) == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
isSelected = HT_IsSelected(node);
|
||||
|
||||
colNum = 0;
|
||||
while (HT_GetNextColumn(cursor, NULL, &colWidth, &colToken, &colTokenType) == TRUE)
|
||||
{
|
||||
if (HT_GetNodeData(node, colToken, colTokenType, &data) == TRUE)
|
||||
{
|
||||
switch(colTokenType)
|
||||
{
|
||||
case HT_COLUMN_DATE_STRING:
|
||||
if (data == NULL) break;
|
||||
if ((dateVal = (time_t)atol((char *)data)) == 0) break;
|
||||
if ((time = localtime(&dateVal)) == NULL) break;
|
||||
|
||||
strftime(buffer,sizeof(buffer),"%#m/%#d/%Y %#I:%M %p",time);
|
||||
#ifdef DEBUG_spence
|
||||
printf ("node: %s\n", buffer);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case HT_COLUMN_DATE_INT:
|
||||
if (data == 0L) break;
|
||||
if ((time = localtime((time_t *) &data)) == NULL) break;
|
||||
|
||||
strftime(buffer,sizeof(buffer),"%#m/%#d/%Y %#I:%M %p",time);
|
||||
#ifdef DEBUG_spence
|
||||
printf ("node: %s\n", buffer);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case HT_COLUMN_INT:
|
||||
sprintf(buffer,"%d",(int)data);
|
||||
#ifdef DEBUG_spence
|
||||
printf ("node: %s\n", buffer);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case HT_COLUMN_STRING:
|
||||
if (data == NULL) break;
|
||||
if (colNum==0)
|
||||
{
|
||||
depth = HT_GetItemIndentation(node) - 1;
|
||||
#ifdef DEBUG_spence
|
||||
printf ("node: %s\n", (char *)data);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_spence
|
||||
printf ("node: %s\n", (char *)data);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isContainer) break;
|
||||
}
|
||||
HT_DeleteColumnCursor(cursor);
|
||||
}
|
||||
|
||||
|
||||
// Outlinable interface methods
|
||||
void *
|
||||
XFE_TreeView::ConvFromIndex (int /* index */)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
XFE_TreeView::ConvToIndex (void * /* item */)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
XFE_TreeView::getColumnName (int /* column */)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
XFE_TreeView::getColumnHeaderText (int /* column */)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fe_icon *
|
||||
XFE_TreeView::getColumnHeaderIcon (int /* column */)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EOutlinerTextStyle
|
||||
XFE_TreeView::getColumnHeaderStyle (int /* column */)
|
||||
{
|
||||
return (EOutlinerTextStyle) NULL;
|
||||
}
|
||||
|
||||
void *
|
||||
XFE_TreeView::acquireLineData (int /* line */)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
XFE_TreeView::getTreeInfo (XP_Bool * /* expandable */, XP_Bool * /* is_expanded */,
|
||||
int * /* depth */, OutlinerAncestorInfo ** /* ancestor */)
|
||||
{
|
||||
}
|
||||
|
||||
EOutlinerTextStyle
|
||||
XFE_TreeView::getColumnStyle (int /* column */)
|
||||
{
|
||||
return (EOutlinerTextStyle) NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
XFE_TreeView::getColumnText (int /* column */)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fe_icon *
|
||||
XFE_TreeView::getColumnIcon (int /* column */)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
XFE_TreeView::releaseLineData()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
XFE_TreeView::Buttonfunc (const OutlineButtonFuncData * /* data */)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
XFE_TreeView::Flippyfunc (const OutlineFlippyFuncData * /* data */)
|
||||
{
|
||||
}
|
||||
|
||||
XFE_Outliner *
|
||||
XFE_TreeView::getOutliner()
|
||||
{
|
||||
return m_outliner;
|
||||
}
|
||||
|
||||
char *
|
||||
XFE_TreeView::getCellTipString (int /* row */, int /* column */)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
XFE_TreeView::getCellDocString (int /* row */, int /* column */)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
extern "C" void
|
||||
fe_showTreeView (Widget parent, int tree_type, int width, int height)
|
||||
{
|
||||
static XP_Bool been_here = FALSE;
|
||||
|
||||
#ifdef DEBUG_spence
|
||||
printf ("XFE_TreeView: showTreeView()\n");
|
||||
#endif
|
||||
|
||||
if (!been_here) {
|
||||
#ifdef DEBUG_spence
|
||||
printf ("RDF_Init()\n");
|
||||
#endif
|
||||
RDF_Init("file://./"); // assume it hasn't been initialized yet
|
||||
been_here = TRUE;
|
||||
}
|
||||
|
||||
XFE_TreeView *tree = new XFE_TreeView ("tree",
|
||||
parent,
|
||||
tree_type,
|
||||
width,
|
||||
height);
|
||||
|
||||
XtRealizeWidget (parent);
|
||||
|
||||
#ifdef DEBUG_spence
|
||||
if (tree == NULL)
|
||||
{
|
||||
printf ("fe_showTreeView: create failed!\n");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
xfe_handleRDFNotify (HT_Notification ns,
|
||||
HT_Resource node,
|
||||
HT_Event event,
|
||||
void *token,
|
||||
uint32 tokenType)
|
||||
{
|
||||
#ifdef DEBUG_spence
|
||||
printf ("handleRDFNotify\n");
|
||||
#endif
|
||||
|
||||
XFE_TreeView *tree = (XFE_TreeView *) ns->data;
|
||||
tree->handleRDFNotify (ns, node, event);
|
||||
}
|
||||
|
||||
120
mozilla/cmd/xfe/src/TreeView.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
TreeView.h -- class definition for XFE_TreeView
|
||||
Created: spence murray <spence@netscape.com>, 3-Nov-97.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _xfe_treeview_h
|
||||
#define _xfe_treeview_h
|
||||
|
||||
#include "NotificationCenter.h"
|
||||
#include "Outlinable.h"
|
||||
#include "XmL/Tree.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "gridpopup.h"
|
||||
#include "htrdf.h"
|
||||
#include "rdf.h"
|
||||
}
|
||||
|
||||
class XFE_TreeView : public XFE_Outlinable
|
||||
{
|
||||
public:
|
||||
XFE_TreeView(const char *name,
|
||||
Widget parent,
|
||||
int tree_type,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
XFE_TreeView();
|
||||
virtual ~XFE_TreeView();
|
||||
|
||||
// The Outlinable interface.
|
||||
void *ConvFromIndex(int index);
|
||||
virtual int ConvToIndex(void *item);
|
||||
virtual char *getColumnName(int column);
|
||||
virtual char *getColumnHeaderText(int column);
|
||||
virtual fe_icon *getColumnHeaderIcon(int column);
|
||||
virtual EOutlinerTextStyle getColumnHeaderStyle(int column);
|
||||
virtual void *acquireLineData(int line);
|
||||
virtual void getTreeInfo(XP_Bool *expandable, XP_Bool *is_expanded, int *depth,
|
||||
OutlinerAncestorInfo **ancestor);
|
||||
virtual EOutlinerTextStyle getColumnStyle(int column);
|
||||
virtual char *getColumnText(int column);
|
||||
virtual fe_icon *getColumnIcon(int column);
|
||||
|
||||
// Tells the Outlinable object that the line data is no
|
||||
// longer needed, and it can free any storage associated with
|
||||
// it.
|
||||
virtual void releaseLineData();
|
||||
|
||||
virtual void Buttonfunc(const OutlineButtonFuncData *data);
|
||||
virtual void Flippyfunc(const OutlineFlippyFuncData *data);
|
||||
|
||||
// return the outliner associated with this outlinable.
|
||||
virtual XFE_Outliner *getOutliner();
|
||||
|
||||
// Get tooltipString & docString;
|
||||
// returned string shall be freed by the callee
|
||||
// row < 0 indicates heading row; otherwise it is a content row
|
||||
// (starting from 0)
|
||||
//
|
||||
virtual char *getCellTipString(int row, int column);
|
||||
virtual char *getCellDocString(int row, int column);
|
||||
|
||||
// the notifyProc
|
||||
void handleRDFNotify (HT_Notification ns,
|
||||
HT_Resource node,
|
||||
HT_Event event);
|
||||
private:
|
||||
// load the RDF database
|
||||
void getRDFDB ();
|
||||
|
||||
// fill the tree with the current RDF database
|
||||
void drawTree ();
|
||||
|
||||
// draw a node
|
||||
void drawNode (HT_Resource node);
|
||||
|
||||
protected:
|
||||
XFE_Outliner *m_outliner;
|
||||
Widget m_tree;
|
||||
|
||||
// rdf handles
|
||||
RDF_Resources m_rdfResources;
|
||||
HT_Pane m_htPane;
|
||||
HT_View m_htView;
|
||||
};
|
||||
|
||||
extern "C" void
|
||||
fe_showTreeView (Widget parent, int tree_type, int width, int height);
|
||||
|
||||
// the notifyProc
|
||||
extern "C" void
|
||||
xfe_handleRDFNotify (HT_Notification ns,
|
||||
HT_Resource node,
|
||||
HT_Event event,
|
||||
void *token,
|
||||
uint32 tokenType);
|
||||
|
||||
#endif /* _xfe_treeview_h */
|
||||
|
||||
81
mozilla/config/dgux.mk
Normal file
@@ -0,0 +1,81 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
######################################################################
|
||||
# Config stuff for Data General DG/UX
|
||||
#
|
||||
# Initial DG/UX port by Marc Fraioli <fraioli@dg-rtp.dg.com>
|
||||
######################################################################
|
||||
#
|
||||
######################################################################
|
||||
# Version-independent
|
||||
######################################################################
|
||||
|
||||
ARCH := dgux
|
||||
CPU_ARCH := x86
|
||||
GFX_ARCH := x
|
||||
|
||||
OS_INCLUDES =
|
||||
G++INCLUDES =
|
||||
LOC_LIB_DIR =
|
||||
MOTIF =
|
||||
MOTIFLIB = -lXm -lXt -lXmu -lX11
|
||||
OS_LIBS = -lgen -lresolv -lsocket -lnsl
|
||||
#DSO_LDFLAGS = -lXm -lXt -lX11 -lsocket -lnsl
|
||||
|
||||
PLATFORM_FLAGS = -DDGUX -Di386 -D_DGUX_SOURCE -D_POSIX4A_DRAFT6_SOURCE
|
||||
MOVEMAIL_FLAGS = -DUSG -DHAVE_STRERROR
|
||||
PORT_FLAGS = -DSVR4 -DSYSV -DNO_CDEFS_H -DNEED_S_ISSOCK -DSYS_BYTEORDER_H -DUSE_NODL_TABS -DMOTIF_WARNINGS_UPSET_JAVA -DMITSHM -DNO_MULTICAST -DHAVE_NETINET_IN_H -DHAVE_REMAINDER
|
||||
PDJAVA_FLAGS =
|
||||
|
||||
OS_CFLAGS = $(PLATFORM_FLAGS) $(PORT_FLAGS) $(MOVEMAIL_FLAGS)
|
||||
|
||||
LOCALE_MAP = $(DEPTH)/cmd/xfe/intl/unixware.lm
|
||||
EN_LOCALE = C
|
||||
DE_LOCALE = de_DE.ISO8859-1
|
||||
FR_LOCALE = fr_FR.ISO8859-1
|
||||
JP_LOCALE = ja
|
||||
SJIS_LOCALE = ja_JP.SJIS
|
||||
KR_LOCALE = ko_KR.EUC
|
||||
CN_LOCALE = zh
|
||||
TW_LOCALE = zh
|
||||
I2_LOCALE = i2
|
||||
|
||||
# BUILD_UNIX_PLUGINS = 1
|
||||
|
||||
######################################################################
|
||||
# Version-specific stuff
|
||||
######################################################################
|
||||
|
||||
|
||||
######################################################################
|
||||
# Overrides for defaults in config.mk (or wherever)
|
||||
######################################################################
|
||||
|
||||
EMACS = /bin/true
|
||||
PERL = /usr/bin/perl
|
||||
ifdef BUILD_OPT
|
||||
OPTIMIZER = -O2
|
||||
else
|
||||
# -g would produce a huge executable.
|
||||
OPTIMIZER =
|
||||
endif
|
||||
|
||||
######################################################################
|
||||
# Other
|
||||
######################################################################
|
||||
|
||||
67
mozilla/directory/Makefile
Normal file
@@ -0,0 +1,67 @@
|
||||
#! gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
# You need to have checked out the LDAP tree at the same level as ns
|
||||
# in order to build LDAP.
|
||||
#
|
||||
|
||||
|
||||
LDAP_DEPTH = ..
|
||||
DEPTH = ..
|
||||
|
||||
include $(LDAP_DEPTH)/config/rules.mk
|
||||
|
||||
all export:: FORCE
|
||||
@if [ -d $(LDAP_DEPTH)/directory/c-sdk/ldap ]; then \
|
||||
cd $(LDAP_DEPTH)/directory/c-sdk/ldap; \
|
||||
$(MAKE) -f Makefile.client $(MFLAGS) export; \
|
||||
else \
|
||||
echo "No LDAP directory -- skipping"; \
|
||||
exit 0; \
|
||||
fi
|
||||
|
||||
libs install:: FORCE
|
||||
@if [ -d $(LDAP_DEPTH)/directory/c-sdk/ldap ]; then \
|
||||
cd $(LDAP_DEPTH)/directory/c-sdk/ldap; \
|
||||
$(MAKE) -f Makefile.client $(MFLAGS) install; \
|
||||
else \
|
||||
echo "No LDAP directory -- skipping"; \
|
||||
exit 0; \
|
||||
fi
|
||||
|
||||
clean clobber:: FORCE
|
||||
@if [ -d $(LDAP_DEPTH)/directory/c-sdk/ldap ]; then \
|
||||
cd $(LDAP_DEPTH)/directory/c-sdk/ldap; \
|
||||
$(MAKE) -f Makefile.client $(MFLAGS) clean; \
|
||||
else \
|
||||
echo "No LDAP directory -- skipping"; \
|
||||
exit 0; \
|
||||
fi
|
||||
|
||||
realclean clobber_all:: FORCE
|
||||
@if [ -d $(LDAP_DEPTH)/directory/c-sdk/ldap ]; then \
|
||||
cd $(LDAP_DEPTH)/directory/c-sdk/ldap; \
|
||||
$(MAKE) -f Makefile.client $(MFLAGS) realclean; \
|
||||
else \
|
||||
echo "No LDAP directory -- skipping"; \
|
||||
exit 0; \
|
||||
fi
|
||||
|
||||
FORCE:
|
||||
137
mozilla/directory/buildjsdk.txt
Normal file
@@ -0,0 +1,137 @@
|
||||
======================================================================
|
||||
NETSCAPE DIRECTORY SDK FOR JAVA:
|
||||
BUILD INSTRUCTIONS
|
||||
Last updated: July 29, 1998
|
||||
======================================================================
|
||||
For information on the Netscape Directory SDK source release,
|
||||
see http://www.mozilla.org/directory/
|
||||
|
||||
Note the following:
|
||||
- The LDAP filter classes (in the netscape.ldap.util package)
|
||||
use the OROMatcher(tm) regular expression package (from ORO Inc.).
|
||||
This is not provided with the source code release. If you want this
|
||||
package, you need to get it from ORO, Inc. (For details, see the
|
||||
ORO, Inc. home page at http://www.oroinc.com/.)
|
||||
|
||||
|
||||
Unix/Linux Build Instructions
|
||||
-----------------------------
|
||||
|
||||
System Requirements:
|
||||
32MB of RAM, 128MB of swap, recommended 64MB of RAM.
|
||||
|
||||
Tool Requirements:
|
||||
Sun Microsystems Java Development Kit (JDK) 1.1.5
|
||||
(or a more recent version)
|
||||
GNU make 3.74 or a more recent version
|
||||
|
||||
Instructions:
|
||||
1. Uncompress and extract the source files by entering the
|
||||
following command (or your preferred variant of this command):
|
||||
|
||||
gzip -dc <filename>.tar.gz | tar -xvf -
|
||||
|
||||
2. Set and unset the following environment variables.
|
||||
|
||||
In csh/tcsh:
|
||||
setenv JAVA_HOME "<directory where the JDK is installed>"
|
||||
For example:
|
||||
setenv JAVA_HOME "/usr/local/jdk1.1.5"
|
||||
setenv CLASSPATH "<location of the JDK classes.zip file>"
|
||||
For example:
|
||||
setenv CLASSPATH "/usr/local/jdk1.1.5/lib/classes.zip"
|
||||
|
||||
In sh/bash/ksh:
|
||||
JAVA_HOME="<directory where the JDK is installed>"
|
||||
CLASSPATH="<location of the JDK classes.zip file>"
|
||||
export JAVA_HOME CLASSPATH
|
||||
|
||||
3. Build the LDAP Java classes by entering the following commands:
|
||||
|
||||
cd mozilla/directory/java-sdk
|
||||
gmake -f ldap.mk
|
||||
|
||||
If you also want the classes packaged in a JAR file,
|
||||
specify "basepackage" as the target:
|
||||
|
||||
gmake -f ldap.mk basepackage
|
||||
|
||||
The SDK will be built and copied into the following directories:
|
||||
mozilla/directory/java-sdk/dist/classes - class files and manifest file
|
||||
mozilla/directory/java-sdk/dist/packages - ldapjdk.jar JAR file
|
||||
(if you've specified "basepackage" as the target)
|
||||
|
||||
|
||||
Windows Build Instructions
|
||||
--------------------------
|
||||
|
||||
System Requirements:
|
||||
Windows NT 3.51 or 4.0 (4.0 preferred).
|
||||
|
||||
Tool Requirements:
|
||||
Sun Microsystems Java Development Kit (JDK) 1.1.5
|
||||
(or a more recent version)
|
||||
GNU Tools for Windows (you can find these on the Internet).
|
||||
Specifically, you'll need:
|
||||
cp.exe
|
||||
rm.exe
|
||||
Here are some sample download sites to find these:
|
||||
Cygnus (http://www.cygnus.com/misc/gnu-win32)
|
||||
GNU (http://www.gnu.org/order/ftp.html)
|
||||
MIT (ftp://prep.ai.mit.edu/pub/gnu)
|
||||
Netscape uses internally modified versions of the following tools:
|
||||
gmake.exe
|
||||
shmsdos.exe
|
||||
uname.exe
|
||||
You can download them from http://www.mozilla.org/download-mozilla.html
|
||||
(click the Windows Build Tools link). When you unzip the file, the
|
||||
tools will be located in the windows\bin\x86 directory.
|
||||
|
||||
All of these tools need to be put in your path.
|
||||
|
||||
Extracting the Source Files:
|
||||
The source files for the Directory SDK are zipped in a file.
|
||||
When unzipping the file, make sure to specify that you want to
|
||||
preserve the directory structure. For example,
|
||||
make sure that "Use Folder Names" is checked.
|
||||
|
||||
Instructions:
|
||||
NOTE: Make sure to run the commands from a standard Windows NT
|
||||
command prompt. Although you may be able to use other shells
|
||||
to build the SDK, you may need to adjust the makefiles for
|
||||
the shell that you are using.
|
||||
1. Set the following environment variables (within the command session,
|
||||
either manually or via a script), or within the system environment
|
||||
through the Control Panel | System control panel):
|
||||
|
||||
set MOZ_SRC=(top of your source tree, drive letter and path.
|
||||
For example, set MOZ_SRC=d:\mozilla_src, if the mozilla
|
||||
directory is at d:\mozilla_src\mozilla.)
|
||||
set JAVA_HOME=(directory where the JDK is installed)
|
||||
For example:
|
||||
set JAVA_HOME=D:\jdk1.1.5
|
||||
set CLASSPATH=(location of the JDK classes.zip file)
|
||||
For example:
|
||||
set CLASSPATH=D:\jdk1.1.5\lib\classes.zip
|
||||
|
||||
In addition, make sure to set your PATH environment variable to
|
||||
include the tools that you have downloaded.
|
||||
|
||||
2. Enter the following commands to build the LDAP Java classes:
|
||||
cd mozilla\directory\java-sdk
|
||||
gmake -f ldap.mk
|
||||
|
||||
If you also want the classes packaged in a JAR file,
|
||||
specify "basepackage" as the target:
|
||||
|
||||
gmake -f ldap.mk basepackage
|
||||
|
||||
The SDK will be built and copied into the following directories:
|
||||
mozilla\directory\java-sdk\dist\classes - class files and manifest file
|
||||
mozilla\directory\java-sdk\dist\packages - ldapjdk.jar JAR file
|
||||
(if you've specified "basepackage" as the target)
|
||||
|
||||
--------------------------------------------------------
|
||||
Copyright (c) 1998 Netscape Communications Corporation.
|
||||
(http://home.netscape.com/misc/contact_info.html)
|
||||
|
||||
154
mozilla/directory/buildsdk.txt
Normal file
@@ -0,0 +1,154 @@
|
||||
======================================================================
|
||||
NETSCAPE DIRECTORY SDK FOR C:
|
||||
BUILD INSTRUCTIONS
|
||||
Last updated: May 31, 1998
|
||||
======================================================================
|
||||
For information on the Netscape Directory SDK source release,
|
||||
see http://www.mozilla.org/directory/
|
||||
|
||||
Unix/Linux Build Instructions
|
||||
-----------------------------
|
||||
|
||||
System Requirements:
|
||||
32MB of RAM, 128MB of swap, recommended 64MB of RAM.
|
||||
|
||||
Tool Requirements:
|
||||
Native C compiler or GNU C/C++ compiler 2.7.2
|
||||
(or a more recent version)
|
||||
GNU make 3.74 or a more recent version
|
||||
|
||||
Instructions:
|
||||
1. Uncompress and extract the source files by entering the
|
||||
following command (or your preferred variant of this command):
|
||||
|
||||
gzip -dc <filename>.tar.gz | tar -xvf -
|
||||
|
||||
2. Set and unset the following environment variables.
|
||||
|
||||
In csh/tcsh:
|
||||
setenv MOZILLA_CLIENT 1
|
||||
setenv NO_MDUPDATE 1
|
||||
setenv MOZ_LDAP_SDK 1
|
||||
unsetenv MOZ_LI
|
||||
unsetenv MOZ_LITE
|
||||
unsetenv MOZ_MEDIUM
|
||||
unsetenv NO_SECURITY
|
||||
|
||||
In sh/bash/ksh:
|
||||
MOZILLA_CLIENT=1
|
||||
NO_MDUPDATE=1
|
||||
MOZ_LDAP_SDK=1
|
||||
export MOZILLA_CLIENT NO_MDUPDATE MOZ_LDAP_SDK
|
||||
unset MOZ_LI
|
||||
unset MOZ_LITE
|
||||
unset MOZ_MEDIUM
|
||||
unset NO_SECURITY
|
||||
|
||||
3. Build the SDK by entering the following commands:
|
||||
|
||||
cd mozilla
|
||||
gmake -f directory/ldapsdk.mk build
|
||||
|
||||
The SDK will be built and copied into the following directories:
|
||||
mozilla/dist/public/ldap - header files
|
||||
mozilla/dist/<architecture>/bin - LDAP API shared object/libraries
|
||||
(libldap.so, liblber.so)
|
||||
|
||||
|
||||
Windows Build Instructions
|
||||
--------------------------
|
||||
|
||||
System Requirements:
|
||||
Windows NT 3.51 or 4.0 (4.0 preferred).
|
||||
|
||||
Tool Requirements:
|
||||
Microsoft Visual C++ version 4.2 or a more recent version
|
||||
GNU Tools for Windows (you can find these on the Internet).
|
||||
Specifically, you'll need:
|
||||
cp.exe
|
||||
rm.exe
|
||||
Here are some sample download sites to find these:
|
||||
Cygnus (http://www.cygnus.com/misc/gnu-win32)
|
||||
GNU (http://www.gnu.org/order/ftp.html)
|
||||
MIT (ftp://prep.ai.mit.edu/pub/gnu)
|
||||
Netscape uses internally modified versions of the following tools:
|
||||
gmake.exe
|
||||
shmsdos.exe
|
||||
uname.exe
|
||||
You can download them from http://www.mozilla.org/download-mozilla.html
|
||||
(click the Windows Build Tools link). When you unzip the file, the
|
||||
tools will be located in the windows\bin\x86 directory.
|
||||
Netscape-developed tools (makedep.exe, txt2rc.exe, waitfor.exe),
|
||||
which are located in the mozilla\cmd\winfe\mkfiles32 directory
|
||||
|
||||
All of these tools need to be put in your path.
|
||||
|
||||
Extracting the Source Files:
|
||||
The source files for the Directory C SDK are zipped in the file
|
||||
ldap-c-sdk.zip. When unzipping the file, make sure to specify
|
||||
that you want to preserve the directory structure. For example,
|
||||
make sure that "Use Folder Names" is checked.
|
||||
|
||||
Instructions:
|
||||
NOTE: Make sure to run the commands from a standard Windows NT
|
||||
command prompt. Although you may be able to use other shells
|
||||
to build the SDK, you may need to adjust the makefiles for
|
||||
the shell that you are using.
|
||||
1. Set the following environment variables (within the command session,
|
||||
either manually or via a script), or within the system environment
|
||||
through the Control Panel | System control panel):
|
||||
set HOME=(your home directory)
|
||||
set MOZ_BITS=32
|
||||
set MOZ_DEBUG=1
|
||||
set MOZ_GOLD=0
|
||||
set MOZ_JAVA=0
|
||||
set MOZ_NT=351 (if running NT 3.51, don't set otherwise)
|
||||
set MOZ_SRC=(top of your source tree, drive letter and path.
|
||||
For example, set MOZ_SRC=d:\mozilla_src, if the mozilla
|
||||
directory is at d:\mozilla_src\mozilla.)
|
||||
set MOZ_TOOLS=(location of the bin directory containing your
|
||||
GNU tools. The build looks for MOZ_TOOLS\bin\gmake.exe,
|
||||
so make sure that the MOZ_TOOLS environment variable
|
||||
is set correctly.)
|
||||
set PATH=%MOZ_TOOLS%\bin;%PATH%
|
||||
set TEMP=(your temp directory)
|
||||
set TMP=(your temp directory)
|
||||
set VERBOSE=1
|
||||
|
||||
Unset the following environment variables:
|
||||
set MOZ_LI=
|
||||
set MOZ_LITE=
|
||||
set MOZ_MEDIUM=
|
||||
|
||||
2. Enter the following commands to build the SDK:
|
||||
cd mozilla\directory
|
||||
nmake -f ldapsdk.mak
|
||||
|
||||
The SDK will be built and copied into the following directories:
|
||||
mozilla\dist\public\ldap - header files
|
||||
mozilla\dist\Win32_d.obj\bin - LDAP API DLL (nsldap32.dll)
|
||||
mozilla\dist\Win32_d.obj\lib - import and static libraries
|
||||
(nsldap32.lib, nsldap32s.lib)
|
||||
|
||||
Notes:
|
||||
This build process does not use Visual C++ generated project files.
|
||||
(Reasons for this include size, maintainability, and the long-term
|
||||
desire to use tools like gmake or plug-and-play developer tools.)
|
||||
This does not preclude you from using the Visual C++ IDE or its debugger.
|
||||
|
||||
Common Build Problems:
|
||||
If the build fails with the message "'.\WIN32' unexpected",
|
||||
you didn't set the environment variables correctly. Check for
|
||||
extra spaces at the end of the set statements (this is a
|
||||
common problem when copying and pasting commands).
|
||||
If directory-related errors are reported, check the full path to
|
||||
the source for any spaces. Make sure that when you originally extracted
|
||||
the source files, you used a utility that understands long filenames.
|
||||
If you are not sure if your extraction utility understands long filenames,
|
||||
use Info-Zip. (You can get this from ftp://ftp.cdrom.com/pub/infozip.)
|
||||
|
||||
|
||||
--------------------------------------------------------
|
||||
Copyright (c) 1998 Netscape Communications Corporation.
|
||||
(http://home.netscape.com/misc/contact_info.html)
|
||||
|
||||
32
mozilla/directory/c-sdk/ldap/Makefile.client
Normal file
@@ -0,0 +1,32 @@
|
||||
DEPTH = ../../..
|
||||
|
||||
SRCDIRS = build include libraries
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
all export:: FORCE
|
||||
@for i in $(SRCDIRS); do \
|
||||
echo " cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) export"; \
|
||||
( cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) export ); \
|
||||
done
|
||||
|
||||
libs install:: FORCE
|
||||
@for i in $(SRCDIRS); do \
|
||||
echo "cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) install"; \
|
||||
( cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) install ); \
|
||||
done
|
||||
|
||||
clean clobber:: FORCE
|
||||
@for i in $(SRCDIRS); do \
|
||||
echo "cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) clean"; \
|
||||
( cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) clean ); \
|
||||
done
|
||||
|
||||
realclean clobber_all:: FORCE
|
||||
@for i in $(SRCDIRS); do \
|
||||
echo "cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) realclean"; \
|
||||
( cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) realclean ); \
|
||||
done
|
||||
|
||||
FORCE:
|
||||
|
||||
23
mozilla/directory/c-sdk/ldap/build/Makefile.client
Normal file
@@ -0,0 +1,23 @@
|
||||
DEPTH = ../../../..
|
||||
|
||||
CSRCS = dirver.c
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
TARGETS = $(OBJDIR)/dirver$(BIN_SUFFIX)
|
||||
|
||||
GARBAGE += $(TARGETS)
|
||||
|
||||
ifeq ($(OS_ARCH), OS2)
|
||||
$(OBJS) = $(addprefix $(OBJDIR)/, $(CSRCS:.c=.o))
|
||||
|
||||
$(TARGETS): $(OBJS)
|
||||
@$(MAKE_OBJDIR)
|
||||
$(LINK_EXE) -OUT:$@ $(OBJS)
|
||||
endif
|
||||
|
||||
export:: $(TARGETS)
|
||||
$(INSTALL) -m 555 $(TARGETS) $(DIST)/bin
|
||||
|
||||
install:: export
|
||||
|
||||
193
mozilla/directory/c-sdk/ldap/build/dirver.c
Normal file
@@ -0,0 +1,193 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
/ Copyright (C) 1996, 1997 Netscape Communications Corporation
|
||||
/ --------------------------------------------------------------------------
|
||||
/
|
||||
/ Name: Netscape File Version Generator
|
||||
/ Platforms: WIN32
|
||||
/ ......................................................................
|
||||
/ This program generates an ascii format of the 64-bit FILEVERSION
|
||||
/ resource identifier used by Windows executable binaries.
|
||||
/
|
||||
/ Usage Syntax:
|
||||
/ fversion <major.minor.patch> [mm/dd/yyyy] [outfile]
|
||||
/ If date is not specified, the current GMT date is used. yyyy must be
|
||||
/ greater than 1980
|
||||
/
|
||||
/ Usage Example:
|
||||
/ fversion 3.0.0
|
||||
/ fversion 6.5.4 1/30/2001
|
||||
/ fversion 6.5.4 1/30/2001 fileversion.h
|
||||
/
|
||||
/ see http://ntsbuild/sd/30ver.htm for specification
|
||||
/ ......................................................................
|
||||
/ Revision History:
|
||||
/ 01-30-97 Initial Version, Andy Hakim (ahakim@netscape.com)
|
||||
/ --------------------------------------------------------------------------*/
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
unsigned _CalcVersion(unsigned nMajor, unsigned nMinor, unsigned nPatch)
|
||||
{
|
||||
unsigned nVersion;
|
||||
nVersion = nMajor;
|
||||
nVersion <<= 5;
|
||||
nVersion += nMinor;
|
||||
nVersion <<= 7;
|
||||
nVersion += nPatch;
|
||||
nVersion &= 0xFFFF;
|
||||
return(nVersion);
|
||||
}
|
||||
|
||||
|
||||
static void _GetVersions(char *szVer, unsigned *nMajor, unsigned *nMinor,
|
||||
unsigned *nPatch)
|
||||
{
|
||||
char szVersion[128];
|
||||
unsigned nReturn = 0;
|
||||
char *szToken;
|
||||
*nMajor = 0;
|
||||
*nMinor = 0;
|
||||
*nPatch = 0;
|
||||
|
||||
strcpy(szVersion, szVer);
|
||||
if(szToken = strtok(szVersion, ".\n"))
|
||||
{
|
||||
*nMajor = atoi(szToken);
|
||||
if(szToken = strtok(NULL, ".\n"))
|
||||
{
|
||||
*nMinor = atoi(szToken);
|
||||
if(szToken = strtok(NULL, ".\n"))
|
||||
{
|
||||
*nPatch = atoi(szToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned _CalcBuildDate(unsigned nYear, unsigned nMonth, unsigned nDay)
|
||||
{
|
||||
unsigned nBuildDate = 0;
|
||||
|
||||
if(nYear < 100) /* they really mean 19xx */
|
||||
nYear += 1900;
|
||||
|
||||
nYear -= 1980;
|
||||
nBuildDate = nYear;
|
||||
nBuildDate <<= 5;
|
||||
nBuildDate += nMonth;
|
||||
nBuildDate <<= 4;
|
||||
nBuildDate += nDay;
|
||||
nBuildDate &= 0xFFFF;
|
||||
return(nBuildDate);
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned _GenBuildDate(char *szBuildDate)
|
||||
{
|
||||
unsigned nReturn = 0;
|
||||
char *szToken;
|
||||
unsigned nYear = 0;
|
||||
unsigned nMonth = 0;
|
||||
unsigned nDay = 0;
|
||||
|
||||
if((szBuildDate) && (strchr(szBuildDate, '\\') || strchr(szBuildDate, '/')) && (szToken = strtok(szBuildDate, "\\/")))
|
||||
{
|
||||
nMonth = atoi(szToken);
|
||||
if(szToken = strtok(NULL, "\\/"))
|
||||
{
|
||||
nDay = atoi(szToken);
|
||||
if(szToken = strtok(NULL, "\\/"))
|
||||
{
|
||||
nYear = atoi(szToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
struct tm *newtime;
|
||||
time_t ltime;
|
||||
|
||||
time( <ime );
|
||||
|
||||
/* Obtain coordinated universal time: */
|
||||
newtime = gmtime( <ime );
|
||||
nYear = newtime->tm_year;
|
||||
nMonth = newtime->tm_mon;
|
||||
nDay = newtime->tm_mday;
|
||||
}
|
||||
|
||||
nReturn = _CalcBuildDate(nYear, nMonth, nDay);
|
||||
return(nReturn);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void ShowHelp(char *szFilename)
|
||||
{
|
||||
char szTemp[128];
|
||||
fprintf(stdout, "%s: Generates ascii format #define for FILEVERSION\n", szFilename);
|
||||
fprintf(stdout, " resource identifier used by Windows executable binaries.\n");
|
||||
fprintf(stdout, "\n");
|
||||
fprintf(stdout, "Usage: %s <major.minor.patch> [mm/dd/yy] [outfile]\n", szFilename);
|
||||
fprintf(stdout, "\n");
|
||||
fprintf(stdout, "Examples:\n");
|
||||
fprintf(stdout, "%s 3.0.0\n", szFilename);
|
||||
fprintf(stdout, "%s 6.5.2 1/30/2001\n", szFilename);
|
||||
fprintf(stdout, "%s 6.5.2 1/30/2001 fileversion.h\n", szFilename);
|
||||
}
|
||||
|
||||
|
||||
|
||||
main(int nArgc, char **lpArgv)
|
||||
{
|
||||
int nReturn = 0;
|
||||
unsigned nVersion = 0;
|
||||
unsigned nBuildDate = 0;
|
||||
|
||||
if(nArgc < 2)
|
||||
{
|
||||
ShowHelp(lpArgv[0]);
|
||||
nReturn = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *szVersion = NULL;
|
||||
char *szDate = NULL;
|
||||
char *szOutput = NULL;
|
||||
FILE *f = stdout;
|
||||
unsigned nMajor = 0;
|
||||
unsigned nMinor = 0;
|
||||
unsigned nPatch = 0;
|
||||
|
||||
szVersion = (char *)lpArgv[1];
|
||||
szDate = (char *)lpArgv[2];
|
||||
szOutput = (char *)lpArgv[3];
|
||||
_GetVersions( szVersion, &nMajor, &nMinor, &nPatch );
|
||||
nVersion = _CalcVersion(nMajor, nMinor, nPatch);
|
||||
nBuildDate = _GenBuildDate(szDate);
|
||||
|
||||
if(nArgc >= 4)
|
||||
f = fopen(szOutput, "w");
|
||||
|
||||
fprintf(f, "#define VI_PRODUCTVERSION %u.%u\n", nMajor, nMinor);
|
||||
fprintf(f, "#define PRODUCTTEXT \"%u.%u\"\n", nMajor, nMinor);
|
||||
fprintf(f, "#define VI_FILEVERSION %u, 0, 0,%u\n",
|
||||
nVersion, nBuildDate);
|
||||
fprintf(f, "#define VI_FileVersion \"%s Build %u\\0\"\n",
|
||||
szVersion, nBuildDate);
|
||||
|
||||
if(nArgc >= 4)
|
||||
fclose(f);
|
||||
nReturn = (nVersion && !nBuildDate);
|
||||
}
|
||||
return(nReturn);
|
||||
}
|
||||
|
||||
4
mozilla/directory/c-sdk/ldap/include/MANIFEST
Normal file
@@ -0,0 +1,4 @@
|
||||
disptmpl.h
|
||||
lber.h
|
||||
ldap.h
|
||||
srchpref.h
|
||||
48
mozilla/directory/c-sdk/ldap/include/Makefile.client
Normal file
@@ -0,0 +1,48 @@
|
||||
DEPTH = ../../../..
|
||||
|
||||
|
||||
CHMOD = chmod
|
||||
RM = rm -f
|
||||
SED = sed
|
||||
|
||||
HEADERS = \
|
||||
disptmpl.h \
|
||||
lber.h \
|
||||
ldap.h \
|
||||
srchpref.h \
|
||||
$(NULL)
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
GARBAGE += sdkver.h dirver.h
|
||||
|
||||
ETCDIR = $(DIST)/etc
|
||||
INCLUDEDIR = $(XPDIST)/public/ldap
|
||||
|
||||
DIR_VERSION := 2.0
|
||||
DIRSDK_VERSION := 1.0
|
||||
|
||||
ifeq ($(OS_ARCH), WINNT)
|
||||
# Is this correct?
|
||||
DIRVER_PATH = $(DEPTH)/netsite/ldap/build
|
||||
else
|
||||
DIRVER_PATH = $(DIST)/bin
|
||||
endif
|
||||
|
||||
DIRVER_PROG = $(DIRVER_PATH)/dirver$(BIN_SUFFIX)
|
||||
|
||||
###########################################################################
|
||||
|
||||
all export:: sdkver.h dirver.h FORCE
|
||||
$(INSTALL) $(INSTALLFLAGS) -m 644 $(HEADERS) $(INCLUDEDIR)
|
||||
$(INSTALL) $(INSTALLFLAGS) -m 644 $(HEADERS) $(DIST)/include
|
||||
|
||||
sdkver.h: $(DIRVER_PROG)
|
||||
@$< $(DIRSDK_VERSION) UseSystemDate $@
|
||||
|
||||
dirver.h: $(DIRVER_PROG)
|
||||
@$< $(DIR_VERSION) UseSystemDate $@
|
||||
|
||||
install:: export
|
||||
|
||||
FORCE:
|
||||
343
mozilla/directory/c-sdk/ldap/include/disptmpl.h
Normal file
@@ -0,0 +1,343 @@
|
||||
/*
|
||||
* Copyright (c) 1993, 1994 Regents of the University of Michigan.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that this notice is preserved and that due credit is given
|
||||
* to the University of Michigan at Ann Arbor. The name of the University
|
||||
* may not be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission. This software
|
||||
* is provided ``as is'' without express or implied warranty.
|
||||
*
|
||||
* disptmpl.h: display template library defines
|
||||
* 7 March 1994 by Mark C Smith
|
||||
*/
|
||||
|
||||
#ifndef _DISPTMPL_H
|
||||
#define _DISPTMPL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* calling conventions used by library */
|
||||
#ifndef LDAP_CALL
|
||||
#if defined( _WINDOWS ) || defined( _WIN32 )
|
||||
#define LDAP_C __cdecl
|
||||
#ifndef _WIN32
|
||||
#define __stdcall _far _pascal
|
||||
#define LDAP_CALLBACK _loadds
|
||||
#else
|
||||
#define LDAP_CALLBACK
|
||||
#endif /* _WIN32 */
|
||||
#define LDAP_PASCAL __stdcall
|
||||
#define LDAP_CALL LDAP_PASCAL
|
||||
#else /* _WINDOWS */
|
||||
#define LDAP_C
|
||||
#define LDAP_CALLBACK
|
||||
#define LDAP_PASCAL
|
||||
#define LDAP_CALL
|
||||
#endif /* _WINDOWS */
|
||||
#endif /* LDAP_CALL */
|
||||
|
||||
#define LDAP_TEMPLATE_VERSION 1
|
||||
|
||||
/*
|
||||
* general types of items (confined to most significant byte)
|
||||
*/
|
||||
#define LDAP_SYN_TYPE_TEXT 0x01000000L
|
||||
#define LDAP_SYN_TYPE_IMAGE 0x02000000L
|
||||
#define LDAP_SYN_TYPE_BOOLEAN 0x04000000L
|
||||
#define LDAP_SYN_TYPE_BUTTON 0x08000000L
|
||||
#define LDAP_SYN_TYPE_ACTION 0x10000000L
|
||||
|
||||
|
||||
/*
|
||||
* syntax options (confined to second most significant byte)
|
||||
*/
|
||||
#define LDAP_SYN_OPT_DEFER 0x00010000L
|
||||
|
||||
|
||||
/*
|
||||
* display template item syntax ids (defined by common agreement)
|
||||
* these are the valid values for the ti_syntaxid of the tmplitem
|
||||
* struct (defined below). A general type is encoded in the
|
||||
* most-significant 8 bits, and some options are encoded in the next
|
||||
* 8 bits. The lower 16 bits are reserved for the distinct types.
|
||||
*/
|
||||
#define LDAP_SYN_CASEIGNORESTR ( 1 | LDAP_SYN_TYPE_TEXT )
|
||||
#define LDAP_SYN_MULTILINESTR ( 2 | LDAP_SYN_TYPE_TEXT )
|
||||
#define LDAP_SYN_DN ( 3 | LDAP_SYN_TYPE_TEXT )
|
||||
#define LDAP_SYN_BOOLEAN ( 4 | LDAP_SYN_TYPE_BOOLEAN )
|
||||
#define LDAP_SYN_JPEGIMAGE ( 5 | LDAP_SYN_TYPE_IMAGE )
|
||||
#define LDAP_SYN_JPEGBUTTON ( 6 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER )
|
||||
#define LDAP_SYN_FAXIMAGE ( 7 | LDAP_SYN_TYPE_IMAGE )
|
||||
#define LDAP_SYN_FAXBUTTON ( 8 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER )
|
||||
#define LDAP_SYN_AUDIOBUTTON ( 9 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER )
|
||||
#define LDAP_SYN_TIME ( 10 | LDAP_SYN_TYPE_TEXT )
|
||||
#define LDAP_SYN_DATE ( 11 | LDAP_SYN_TYPE_TEXT )
|
||||
#define LDAP_SYN_LABELEDURL ( 12 | LDAP_SYN_TYPE_TEXT )
|
||||
#define LDAP_SYN_SEARCHACTION ( 13 | LDAP_SYN_TYPE_ACTION )
|
||||
#define LDAP_SYN_LINKACTION ( 14 | LDAP_SYN_TYPE_ACTION )
|
||||
#define LDAP_SYN_ADDDNACTION ( 15 | LDAP_SYN_TYPE_ACTION )
|
||||
#define LDAP_SYN_VERIFYDNACTION ( 16 | LDAP_SYN_TYPE_ACTION )
|
||||
#define LDAP_SYN_RFC822ADDR ( 17 | LDAP_SYN_TYPE_TEXT )
|
||||
|
||||
|
||||
/*
|
||||
* handy macros
|
||||
*/
|
||||
#define LDAP_GET_SYN_TYPE( syid ) ((syid) & 0xFF000000L )
|
||||
#define LDAP_GET_SYN_OPTIONS( syid ) ((syid) & 0x00FF0000L )
|
||||
|
||||
|
||||
/*
|
||||
* display options for output routines (used by entry2text and friends)
|
||||
*/
|
||||
/*
|
||||
* use calculated label width (based on length of longest label in
|
||||
* template) instead of contant width
|
||||
*/
|
||||
#define LDAP_DISP_OPT_AUTOLABELWIDTH 0x00000001L
|
||||
#define LDAP_DISP_OPT_HTMLBODYONLY 0x00000002L
|
||||
|
||||
/*
|
||||
* perform search actions (applies to ldap_entry2text_search only)
|
||||
*/
|
||||
#define LDAP_DISP_OPT_DOSEARCHACTIONS 0x00000002L
|
||||
|
||||
/*
|
||||
* include additional info. relevant to "non leaf" entries only
|
||||
* used by ldap_entry2html and ldap_entry2html_search to include "Browse"
|
||||
* and "Move Up" HREFs
|
||||
*/
|
||||
#define LDAP_DISP_OPT_NONLEAF 0x00000004L
|
||||
|
||||
|
||||
/*
|
||||
* display template item options (may not apply to all types)
|
||||
* if this bit is set in ti_options, it applies.
|
||||
*/
|
||||
#define LDAP_DITEM_OPT_READONLY 0x00000001L
|
||||
#define LDAP_DITEM_OPT_SORTVALUES 0x00000002L
|
||||
#define LDAP_DITEM_OPT_SINGLEVALUED 0x00000004L
|
||||
#define LDAP_DITEM_OPT_HIDEIFEMPTY 0x00000008L
|
||||
#define LDAP_DITEM_OPT_VALUEREQUIRED 0x00000010L
|
||||
#define LDAP_DITEM_OPT_HIDEIFFALSE 0x00000020L /* booleans only */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* display template item structure
|
||||
*/
|
||||
struct ldap_tmplitem {
|
||||
unsigned long ti_syntaxid;
|
||||
unsigned long ti_options;
|
||||
char *ti_attrname;
|
||||
char *ti_label;
|
||||
char **ti_args;
|
||||
struct ldap_tmplitem *ti_next_in_row;
|
||||
struct ldap_tmplitem *ti_next_in_col;
|
||||
void *ti_appdata;
|
||||
};
|
||||
|
||||
|
||||
#define NULLTMPLITEM ((struct ldap_tmplitem *)0)
|
||||
|
||||
#define LDAP_SET_TMPLITEM_APPDATA( ti, datap ) \
|
||||
(ti)->ti_appdata = (void *)(datap)
|
||||
|
||||
#define LDAP_GET_TMPLITEM_APPDATA( ti, type ) \
|
||||
(type)((ti)->ti_appdata)
|
||||
|
||||
#define LDAP_IS_TMPLITEM_OPTION_SET( ti, option ) \
|
||||
(((ti)->ti_options & option ) != 0 )
|
||||
|
||||
|
||||
/*
|
||||
* object class array structure
|
||||
*/
|
||||
struct ldap_oclist {
|
||||
char **oc_objclasses;
|
||||
struct ldap_oclist *oc_next;
|
||||
};
|
||||
|
||||
#define NULLOCLIST ((struct ldap_oclist *)0)
|
||||
|
||||
|
||||
/*
|
||||
* add defaults list
|
||||
*/
|
||||
struct ldap_adddeflist {
|
||||
int ad_source;
|
||||
#define LDAP_ADSRC_CONSTANTVALUE 1
|
||||
#define LDAP_ADSRC_ADDERSDN 2
|
||||
char *ad_attrname;
|
||||
char *ad_value;
|
||||
struct ldap_adddeflist *ad_next;
|
||||
};
|
||||
|
||||
#define NULLADLIST ((struct ldap_adddeflist *)0)
|
||||
|
||||
|
||||
/*
|
||||
* display template global options
|
||||
* if this bit is set in dt_options, it applies.
|
||||
*/
|
||||
/*
|
||||
* users should be allowed to try to add objects of these entries
|
||||
*/
|
||||
#define LDAP_DTMPL_OPT_ADDABLE 0x00000001L
|
||||
|
||||
/*
|
||||
* users should be allowed to do "modify RDN" operation of these entries
|
||||
*/
|
||||
#define LDAP_DTMPL_OPT_ALLOWMODRDN 0x00000002L
|
||||
|
||||
/*
|
||||
* this template is an alternate view, not a primary view
|
||||
*/
|
||||
#define LDAP_DTMPL_OPT_ALTVIEW 0x00000004L
|
||||
|
||||
|
||||
/*
|
||||
* display template structure
|
||||
*/
|
||||
struct ldap_disptmpl {
|
||||
char *dt_name;
|
||||
char *dt_pluralname;
|
||||
char *dt_iconname;
|
||||
unsigned long dt_options;
|
||||
char *dt_authattrname;
|
||||
char *dt_defrdnattrname;
|
||||
char *dt_defaddlocation;
|
||||
struct ldap_oclist *dt_oclist;
|
||||
struct ldap_adddeflist *dt_adddeflist;
|
||||
struct ldap_tmplitem *dt_items;
|
||||
void *dt_appdata;
|
||||
struct ldap_disptmpl *dt_next;
|
||||
};
|
||||
|
||||
#define NULLDISPTMPL ((struct ldap_disptmpl *)0)
|
||||
|
||||
#define LDAP_SET_DISPTMPL_APPDATA( dt, datap ) \
|
||||
(dt)->dt_appdata = (void *)(datap)
|
||||
|
||||
#define LDAP_GET_DISPTMPL_APPDATA( dt, type ) \
|
||||
(type)((dt)->dt_appdata)
|
||||
|
||||
#define LDAP_IS_DISPTMPL_OPTION_SET( dt, option ) \
|
||||
(((dt)->dt_options & option ) != 0 )
|
||||
|
||||
#define LDAP_TMPL_ERR_VERSION 1
|
||||
#define LDAP_TMPL_ERR_MEM 2
|
||||
#define LDAP_TMPL_ERR_SYNTAX 3
|
||||
#define LDAP_TMPL_ERR_FILE 4
|
||||
|
||||
/*
|
||||
* buffer size needed for entry2text and vals2text
|
||||
*/
|
||||
#define LDAP_DTMPL_BUFSIZ 8192
|
||||
|
||||
typedef int (*writeptype)( void *writeparm, char *p, int len );
|
||||
|
||||
LDAP_API(int)
|
||||
LDAP_CALL
|
||||
ldap_init_templates( char *file, struct ldap_disptmpl **tmpllistp );
|
||||
|
||||
LDAP_API(int)
|
||||
LDAP_CALL
|
||||
ldap_init_templates_buf( char *buf, long buflen,
|
||||
struct ldap_disptmpl **tmpllistp );
|
||||
|
||||
LDAP_API(void)
|
||||
LDAP_CALL
|
||||
ldap_free_templates( struct ldap_disptmpl *tmpllist );
|
||||
|
||||
LDAP_API(struct ldap_disptmpl *)
|
||||
LDAP_CALL
|
||||
ldap_first_disptmpl( struct ldap_disptmpl *tmpllist );
|
||||
|
||||
LDAP_API(struct ldap_disptmpl *)
|
||||
LDAP_CALL
|
||||
ldap_next_disptmpl( struct ldap_disptmpl *tmpllist,
|
||||
struct ldap_disptmpl *tmpl );
|
||||
|
||||
LDAP_API(struct ldap_disptmpl *)
|
||||
LDAP_CALL
|
||||
ldap_name2template( char *name, struct ldap_disptmpl *tmpllist );
|
||||
|
||||
LDAP_API(struct ldap_disptmpl *)
|
||||
LDAP_CALL
|
||||
ldap_oc2template( char **oclist, struct ldap_disptmpl *tmpllist );
|
||||
|
||||
LDAP_API(char **)
|
||||
LDAP_CALL
|
||||
ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs, int exclude,
|
||||
unsigned long syntaxmask );
|
||||
|
||||
LDAP_API(struct ldap_tmplitem *)
|
||||
LDAP_CALL
|
||||
ldap_first_tmplrow( struct ldap_disptmpl *tmpl );
|
||||
|
||||
LDAP_API(struct ldap_tmplitem *)
|
||||
LDAP_CALL
|
||||
ldap_next_tmplrow( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row );
|
||||
|
||||
LDAP_API(struct ldap_tmplitem *)
|
||||
LDAP_CALL
|
||||
ldap_first_tmplcol( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row );
|
||||
|
||||
LDAP_API(struct ldap_tmplitem *)
|
||||
LDAP_CALL
|
||||
ldap_next_tmplcol( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row,
|
||||
struct ldap_tmplitem *col );
|
||||
|
||||
LDAP_API(int)
|
||||
LDAP_CALL
|
||||
ldap_entry2text( LDAP *ld, char *buf, LDAPMessage *entry,
|
||||
struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
|
||||
writeptype writeproc, void *writeparm, char *eol, int rdncount,
|
||||
unsigned long opts );
|
||||
|
||||
LDAP_API(int)
|
||||
LDAP_CALL
|
||||
ldap_vals2text( LDAP *ld, char *buf, char **vals, char *label, int labelwidth,
|
||||
unsigned long syntaxid, writeptype writeproc, void *writeparm,
|
||||
char *eol, int rdncount );
|
||||
|
||||
LDAP_API(int)
|
||||
LDAP_CALL
|
||||
ldap_entry2text_search( LDAP *ld, char *dn, char *base, LDAPMessage *entry,
|
||||
struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals,
|
||||
writeptype writeproc, void *writeparm, char *eol, int rdncount,
|
||||
unsigned long opts );
|
||||
|
||||
LDAP_API(int)
|
||||
LDAP_CALL
|
||||
ldap_entry2html( LDAP *ld, char *buf, LDAPMessage *entry,
|
||||
struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
|
||||
writeptype writeproc, void *writeparm, char *eol, int rdncount,
|
||||
unsigned long opts, char *urlprefix, char *base );
|
||||
|
||||
LDAP_API(int)
|
||||
LDAP_CALL
|
||||
ldap_vals2html( LDAP *ld, char *buf, char **vals, char *label, int labelwidth,
|
||||
unsigned long syntaxid, writeptype writeproc, void *writeparm,
|
||||
char *eol, int rdncount, char *urlprefix );
|
||||
|
||||
LDAP_API(int)
|
||||
LDAP_CALL
|
||||
ldap_entry2html_search( LDAP *ld, char *dn, char *base, LDAPMessage *entry,
|
||||
struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals,
|
||||
writeptype writeproc, void *writeparm, char *eol, int rdncount,
|
||||
unsigned long opts, char *urlprefix );
|
||||
|
||||
LDAP_API(char *)
|
||||
LDAP_CALL
|
||||
ldap_tmplerr2string( int err );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _DISPTMPL_H */
|
||||
257
mozilla/directory/c-sdk/ldap/include/lber.h
Normal file
@@ -0,0 +1,257 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* lber.h - header file for ber_* functions */
|
||||
#ifndef _LBER_H
|
||||
#define _LBER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdlib.h> /* to pick up size_t typedef */
|
||||
|
||||
/*
|
||||
* Note that LBER_ERROR and LBER_DEFAULT are values that can never appear
|
||||
* as valid BER tags, and so it is safe to use them to report errors. In
|
||||
* fact, any tag for which the following is true is invalid:
|
||||
* (( tag & 0x00000080 ) != 0 ) && (( tag & 0xFFFFFF00 ) != 0 )
|
||||
*/
|
||||
#define LBER_ERROR 0xffffffffL
|
||||
#define LBER_DEFAULT LBER_ERROR
|
||||
#define LBER_END_OF_SEQORSET 0xfffffffeL
|
||||
|
||||
/* BER classes and mask */
|
||||
#define LBER_CLASS_UNIVERSAL 0x00
|
||||
#define LBER_CLASS_APPLICATION 0x40
|
||||
#define LBER_CLASS_CONTEXT 0x80
|
||||
#define LBER_CLASS_PRIVATE 0xc0
|
||||
#define LBER_CLASS_MASK 0xc0
|
||||
|
||||
/* BER encoding type and mask */
|
||||
#define LBER_PRIMITIVE 0x00
|
||||
#define LBER_CONSTRUCTED 0x20
|
||||
#define LBER_ENCODING_MASK 0x20
|
||||
|
||||
#define LBER_BIG_TAG_MASK 0x1f
|
||||
#define LBER_MORE_TAG_MASK 0x80
|
||||
|
||||
/* general BER types we know about */
|
||||
#define LBER_BOOLEAN 0x01L
|
||||
#define LBER_INTEGER 0x02L
|
||||
#define LBER_BITSTRING 0x03L
|
||||
#define LBER_OCTETSTRING 0x04L
|
||||
#define LBER_NULL 0x05L
|
||||
#define LBER_ENUMERATED 0x0aL
|
||||
#define LBER_SEQUENCE 0x30L
|
||||
#define LBER_SET 0x31L
|
||||
|
||||
/* BerElement set/get options */
|
||||
#define LBER_OPT_REMAINING_BYTES 0x01
|
||||
#define LBER_OPT_TOTAL_BYTES 0x02
|
||||
#define LBER_OPT_USE_DER 0x04
|
||||
#define LBER_OPT_TRANSLATE_STRINGS 0x08
|
||||
#define LBER_OPT_BYTES_TO_WRITE 0x10
|
||||
#define LBER_OPT_MEMALLOC_FN_PTRS 0x20
|
||||
|
||||
/* Sockbuf set/get options */
|
||||
#define LBER_SOCKBUF_OPT_TO_FILE 0x001
|
||||
#define LBER_SOCKBUF_OPT_TO_FILE_ONLY 0x002
|
||||
#define LBER_SOCKBUF_OPT_MAX_INCOMING_SIZE 0x004
|
||||
#define LBER_SOCKBUF_OPT_NO_READ_AHEAD 0x008
|
||||
#define LBER_SOCKBUF_OPT_DESC 0x010
|
||||
#define LBER_SOCKBUF_OPT_COPYDESC 0x020
|
||||
#define LBER_SOCKBUF_OPT_READ_FN 0x040
|
||||
#define LBER_SOCKBUF_OPT_WRITE_FN 0x080
|
||||
|
||||
#define LBER_OPT_ON ((void *) 1)
|
||||
#define LBER_OPT_OFF ((void *) 0)
|
||||
|
||||
extern int lber_debug;
|
||||
|
||||
struct berval {
|
||||
unsigned long bv_len;
|
||||
char *bv_val;
|
||||
};
|
||||
|
||||
typedef struct berelement BerElement;
|
||||
typedef struct sockbuf Sockbuf;
|
||||
typedef int (*BERTranslateProc)( char **bufp, unsigned long *buflenp,
|
||||
int free_input );
|
||||
#ifndef macintosh
|
||||
#if defined( _WINDOWS ) || defined( _WIN32) || defined( _CONSOLE )
|
||||
#include <winsock.h> /* for SOCKET */
|
||||
typedef SOCKET LBER_SOCKET;
|
||||
#else
|
||||
typedef int LBER_SOCKET;
|
||||
#endif /* _WINDOWS */
|
||||
#else /* macintosh */
|
||||
typedef void *LBER_SOCKET;
|
||||
#endif /* macintosh */
|
||||
|
||||
/* calling conventions used by library */
|
||||
#ifndef LDAP_CALL
|
||||
#if defined( _WINDOWS ) || defined( _WIN32 )
|
||||
#define LDAP_C __cdecl
|
||||
#ifndef _WIN32
|
||||
#define __stdcall _far _pascal
|
||||
#define LDAP_CALLBACK _loadds
|
||||
#else
|
||||
#define LDAP_CALLBACK
|
||||
#endif /* _WIN32 */
|
||||
#define LDAP_PASCAL __stdcall
|
||||
#define LDAP_CALL LDAP_PASCAL
|
||||
#else /* _WINDOWS */
|
||||
#define LDAP_C
|
||||
#define LDAP_CALLBACK
|
||||
#define LDAP_PASCAL
|
||||
#define LDAP_CALL
|
||||
#endif /* _WINDOWS */
|
||||
#endif /* LDAP_CALL */
|
||||
|
||||
/*
|
||||
* function prototypes for lber library
|
||||
*/
|
||||
|
||||
#ifndef LDAP_API
|
||||
#if defined( _WINDOWS ) || defined( _WIN32 )
|
||||
#define LDAP_API(rt) rt
|
||||
#else /* _WINDOWS */
|
||||
#define LDAP_API(rt) rt
|
||||
#endif /* _WINDOWS */
|
||||
#endif /* LDAP_API */
|
||||
|
||||
/*
|
||||
* libldap read and write I/O function callbacks. The rest of the I/O callback
|
||||
* types are in ldap.h
|
||||
*/
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_READ_CALLBACK)( LBER_SOCKET,
|
||||
void *, int );
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_WRITE_CALLBACK)( LBER_SOCKET,
|
||||
const void *, int );
|
||||
|
||||
/*
|
||||
* liblber memory allocation callback functions. These are global to all
|
||||
* Sockbufs and BerElements. Install your own functions by using a call
|
||||
* like this: ber_set_option( NULL, LBER_OPT_MEMALLOC_FN_PTRS, &memalloc_fns );
|
||||
*/
|
||||
typedef void * (LDAP_C LDAP_CALLBACK LDAP_MALLOC_CALLBACK)( size_t size );
|
||||
typedef void * (LDAP_C LDAP_CALLBACK LDAP_CALLOC_CALLBACK)( size_t nelem,
|
||||
size_t elsize );
|
||||
typedef void * (LDAP_C LDAP_CALLBACK LDAP_REALLOC_CALLBACK)( void *ptr,
|
||||
size_t size );
|
||||
typedef void (LDAP_C LDAP_CALLBACK LDAP_FREE_CALLBACK)( void *ptr );
|
||||
|
||||
struct lber_memalloc_fns {
|
||||
LDAP_MALLOC_CALLBACK *lbermem_malloc;
|
||||
LDAP_CALLOC_CALLBACK *lbermem_calloc;
|
||||
LDAP_REALLOC_CALLBACK *lbermem_realloc;
|
||||
LDAP_FREE_CALLBACK *lbermem_free;
|
||||
};
|
||||
|
||||
/*
|
||||
* decode routines
|
||||
*/
|
||||
LDAP_API(unsigned long) LDAP_CALL ber_get_tag( BerElement *ber );
|
||||
LDAP_API(unsigned long) LDAP_CALL ber_skip_tag( BerElement *ber,
|
||||
unsigned long *len );
|
||||
LDAP_API(unsigned long) LDAP_CALL ber_peek_tag( BerElement *ber,
|
||||
unsigned long *len );
|
||||
LDAP_API(unsigned long) LDAP_CALL ber_get_int( BerElement *ber, long *num );
|
||||
LDAP_API(unsigned long) LDAP_CALL ber_get_stringb( BerElement *ber, char *buf,
|
||||
unsigned long *len );
|
||||
LDAP_API(unsigned long) LDAP_CALL ber_get_stringa( BerElement *ber,
|
||||
char **buf );
|
||||
LDAP_API(unsigned long) LDAP_CALL ber_get_stringal( BerElement *ber,
|
||||
struct berval **bv );
|
||||
LDAP_API(unsigned long) LDAP_CALL ber_get_bitstringa( BerElement *ber,
|
||||
char **buf, unsigned long *len );
|
||||
LDAP_API(unsigned long) LDAP_CALL ber_get_null( BerElement *ber );
|
||||
LDAP_API(unsigned long) LDAP_CALL ber_get_boolean( BerElement *ber,
|
||||
int *boolval );
|
||||
LDAP_API(unsigned long) LDAP_CALL ber_first_element( BerElement *ber,
|
||||
unsigned long *len, char **last );
|
||||
LDAP_API(unsigned long) LDAP_CALL ber_next_element( BerElement *ber,
|
||||
unsigned long *len, char *last );
|
||||
LDAP_API(unsigned long) LDAP_C ber_scanf( BerElement *ber, char *fmt, ... );
|
||||
LDAP_API(void) LDAP_CALL ber_bvfree( struct berval *bv );
|
||||
LDAP_API(void) LDAP_CALL ber_bvecfree( struct berval **bv );
|
||||
LDAP_API(struct berval *) LDAP_CALL ber_bvdup( struct berval *bv );
|
||||
LDAP_API(void) LDAP_CALL ber_set_string_translators( BerElement *ber,
|
||||
BERTranslateProc encode_proc, BERTranslateProc decode_proc );
|
||||
LDAP_API(BerElement *) LDAP_CALL ber_init ( struct berval *bv );
|
||||
|
||||
/*
|
||||
* encoding routines
|
||||
*/
|
||||
LDAP_API(int) LDAP_CALL ber_put_enum( BerElement *ber, long num,
|
||||
unsigned long tag );
|
||||
LDAP_API(int) LDAP_CALL ber_put_int( BerElement *ber, long num,
|
||||
unsigned long tag );
|
||||
LDAP_API(int) LDAP_CALL ber_put_ostring( BerElement *ber, char *str,
|
||||
unsigned long len, unsigned long tag );
|
||||
LDAP_API(int) LDAP_CALL ber_put_string( BerElement *ber, char *str,
|
||||
unsigned long tag );
|
||||
LDAP_API(int) LDAP_CALL ber_put_bitstring( BerElement *ber, char *str,
|
||||
unsigned long bitlen, unsigned long tag );
|
||||
LDAP_API(int) LDAP_CALL ber_put_null( BerElement *ber, unsigned long tag );
|
||||
LDAP_API(int) LDAP_CALL ber_put_boolean( BerElement *ber, int boolval,
|
||||
unsigned long tag );
|
||||
LDAP_API(int) LDAP_CALL ber_start_seq( BerElement *ber, unsigned long tag );
|
||||
LDAP_API(int) LDAP_CALL ber_start_set( BerElement *ber, unsigned long tag );
|
||||
LDAP_API(int) LDAP_CALL ber_put_seq( BerElement *ber );
|
||||
LDAP_API(int) LDAP_CALL ber_put_set( BerElement *ber );
|
||||
LDAP_API(int) LDAP_C ber_printf( BerElement *ber, char *fmt, ... );
|
||||
LDAP_API(int) LDAP_CALL ber_flatten( BerElement *ber, struct berval **bvPtr );
|
||||
|
||||
/*
|
||||
* miscellaneous routines
|
||||
*/
|
||||
LDAP_API(void) LDAP_CALL ber_free( BerElement *ber, int freebuf );
|
||||
LDAP_API(void) LDAP_CALL ber_special_free(void* buf, BerElement *ber);
|
||||
LDAP_API(int) LDAP_CALL ber_flush( Sockbuf *sb, BerElement *ber, int freeit );
|
||||
LDAP_API(BerElement*) LDAP_CALL ber_alloc( void );
|
||||
LDAP_API(BerElement*) LDAP_CALL der_alloc( void );
|
||||
LDAP_API(BerElement*) LDAP_CALL ber_alloc_t( int options );
|
||||
LDAP_API(void*) LDAP_CALL ber_special_alloc(size_t size, BerElement **ppBer);
|
||||
LDAP_API(BerElement*) LDAP_CALL ber_dup( BerElement *ber );
|
||||
LDAP_API(unsigned long) LDAP_CALL ber_get_next( Sockbuf *sb, unsigned long *len,
|
||||
BerElement *ber );
|
||||
LDAP_API(unsigned long) LDAP_CALL ber_get_next_buffer( void *buffer,
|
||||
size_t buffer_size, unsigned long *len, BerElement *ber,
|
||||
unsigned long *Bytes_Scanned );
|
||||
LDAP_API(long) LDAP_CALL ber_read( BerElement *ber, char *buf,
|
||||
unsigned long len );
|
||||
LDAP_API(long) LDAP_CALL ber_write( BerElement *ber, char *buf,
|
||||
unsigned long len, int nosos );
|
||||
LDAP_API(void) LDAP_CALL ber_init_w_nullchar( BerElement *ber, int options );
|
||||
LDAP_API(void) LDAP_CALL ber_reset( BerElement *ber, int was_writing );
|
||||
LDAP_API(int) LDAP_CALL ber_set_option( BerElement *ber, int option,
|
||||
void *value );
|
||||
LDAP_API(int) LDAP_CALL ber_get_option( BerElement *ber, int option,
|
||||
void *value );
|
||||
LDAP_API(Sockbuf*) LDAP_CALL ber_sockbuf_alloc( void );
|
||||
LDAP_API(void) LDAP_CALL ber_sockbuf_free( Sockbuf* p );
|
||||
LDAP_API(int) LDAP_CALL ber_sockbuf_set_option( Sockbuf *sb, int option,
|
||||
void *value );
|
||||
LDAP_API(int) LDAP_CALL ber_sockbuf_get_option( Sockbuf *sb, int option,
|
||||
void *value );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _LBER_H */
|
||||
964
mozilla/directory/c-sdk/ldap/include/ldap.h
Normal file
@@ -0,0 +1,964 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* ldap.h - general header file for libldap */
|
||||
#ifndef _LDAP_H
|
||||
#define _LDAP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined( XP_OS2 )
|
||||
#include "os2sock.h"
|
||||
#elif defined (WIN32) || defined (_WIN32) || defined( _CONSOLE )
|
||||
#include <windows.h>
|
||||
# if defined( _WINDOWS )
|
||||
# include <winsock.h>
|
||||
# endif
|
||||
#elif defined(macintosh)
|
||||
#include <utime.h>
|
||||
#include "macsocket.h"
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#ifdef _AIX
|
||||
#include <sys/select.h>
|
||||
#endif /* _AIX */
|
||||
|
||||
#include "lber.h"
|
||||
|
||||
#define LDAP_PORT 389
|
||||
#define LDAPS_PORT 636
|
||||
#define LDAP_PORT_MAX 65535
|
||||
#define LDAP_VERSION1 1
|
||||
#define LDAP_VERSION2 2
|
||||
#define LDAP_VERSION3 3
|
||||
#define LDAP_VERSION LDAP_VERSION2 /* default should stay as LDAPv2 */
|
||||
#define LDAP_VERSION_MAX LDAP_VERSION3
|
||||
|
||||
#define LDAP_ROOT_DSE ""
|
||||
#define LDAP_NO_ATTRS "1.1"
|
||||
#define LDAP_ALL_USER_ATTRS "*"
|
||||
|
||||
#define LDAP_OPT_DESC 1
|
||||
#define LDAP_OPT_DEREF 2
|
||||
#define LDAP_OPT_SIZELIMIT 3
|
||||
#define LDAP_OPT_TIMELIMIT 4
|
||||
#define LDAP_OPT_THREAD_FN_PTRS 5
|
||||
#define LDAP_OPT_REBIND_FN 6
|
||||
#define LDAP_OPT_REBIND_ARG 7
|
||||
#define LDAP_OPT_REFERRALS 8
|
||||
#define LDAP_OPT_RESTART 9
|
||||
#define LDAP_OPT_SSL 10
|
||||
#define LDAP_OPT_IO_FN_PTRS 11
|
||||
#define LDAP_OPT_CACHE_FN_PTRS 13
|
||||
#define LDAP_OPT_CACHE_STRATEGY 14
|
||||
#define LDAP_OPT_CACHE_ENABLE 15
|
||||
#define LDAP_OPT_REFERRAL_HOP_LIMIT 16
|
||||
#define LDAP_OPT_PROTOCOL_VERSION 17
|
||||
#define LDAP_OPT_SERVER_CONTROLS 18
|
||||
#define LDAP_OPT_CLIENT_CONTROLS 19
|
||||
#define LDAP_OPT_PREFERRED_LANGUAGE 20
|
||||
#define LDAP_OPT_ERROR_NUMBER 49
|
||||
#define LDAP_OPT_ERROR_STRING 50
|
||||
|
||||
/* for on/off options */
|
||||
#define LDAP_OPT_ON ((void *)1)
|
||||
#define LDAP_OPT_OFF ((void *)0)
|
||||
|
||||
extern int ldap_debug;
|
||||
/* On UNIX, there's only one copy of ldap_debug */
|
||||
/* On NT, each dll keeps its own module_ldap_debug, which */
|
||||
/* points to the process' ldap_debug and needs initializing after load */
|
||||
#ifdef _WIN32
|
||||
extern int *module_ldap_debug;
|
||||
typedef void (*set_debug_level_fn_t)(int*);
|
||||
#endif
|
||||
|
||||
typedef struct ldap LDAP; /* opaque connection handle */
|
||||
typedef struct ldapmsg LDAPMessage; /* opaque result/entry handle */
|
||||
|
||||
#define NULLMSG ((LDAPMessage *)0)
|
||||
|
||||
/* structure representing an LDAP modification */
|
||||
typedef struct ldapmod {
|
||||
int mod_op; /* kind of mod + form of values*/
|
||||
#define LDAP_MOD_ADD 0x00
|
||||
#define LDAP_MOD_DELETE 0x01
|
||||
#define LDAP_MOD_REPLACE 0x02
|
||||
#define LDAP_MOD_BVALUES 0x80
|
||||
char *mod_type; /* attribute name to modify */
|
||||
union {
|
||||
char **modv_strvals;
|
||||
struct berval **modv_bvals;
|
||||
} mod_vals; /* values to add/delete/replace */
|
||||
#define mod_values mod_vals.modv_strvals
|
||||
#define mod_bvalues mod_vals.modv_bvals
|
||||
} LDAPMod;
|
||||
|
||||
/*
|
||||
* thread function callbacks
|
||||
*/
|
||||
typedef void *(LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_ALLOC_CALLBACK)( void );
|
||||
typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_FREE_CALLBACK)( void * );
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_LOCK_CALLBACK)( void * );
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_UNLOCK_CALLBACK)( void * );
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_GET_ERRNO_CALLBACK)( void );
|
||||
typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_SET_ERRNO_CALLBACK)( int );
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_GET_LDERRNO_CALLBACK)( char **,
|
||||
char **, void * );
|
||||
typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_SET_LDERRNO_CALLBACK)( int,
|
||||
char *, char *, void * );
|
||||
|
||||
/*
|
||||
* structure to hold thread function pointers
|
||||
*/
|
||||
struct ldap_thread_fns {
|
||||
LDAP_TF_MUTEX_ALLOC_CALLBACK *ltf_mutex_alloc;
|
||||
LDAP_TF_MUTEX_FREE_CALLBACK *ltf_mutex_free;
|
||||
LDAP_TF_MUTEX_LOCK_CALLBACK *ltf_mutex_lock;
|
||||
LDAP_TF_MUTEX_UNLOCK_CALLBACK *ltf_mutex_unlock;
|
||||
LDAP_TF_GET_ERRNO_CALLBACK *ltf_get_errno;
|
||||
LDAP_TF_SET_ERRNO_CALLBACK *ltf_set_errno;
|
||||
LDAP_TF_GET_LDERRNO_CALLBACK *ltf_get_lderrno;
|
||||
LDAP_TF_SET_LDERRNO_CALLBACK *ltf_set_lderrno;
|
||||
void *ltf_lderrno_arg;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* I/O function callbacks. Note that types for the read and write callbacks
|
||||
* are actually in lber.h
|
||||
*/
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_SELECT_CALLBACK)( int, fd_set *,
|
||||
fd_set *, fd_set *, struct timeval * );
|
||||
typedef LBER_SOCKET (LDAP_C LDAP_CALLBACK LDAP_IOF_SOCKET_CALLBACK)( int,
|
||||
int, int );
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_IOCTL_CALLBACK)( LBER_SOCKET,
|
||||
int, ... );
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_CONNECT_CALLBACK )( LBER_SOCKET,
|
||||
struct sockaddr *, int );
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_CLOSE_CALLBACK )( LBER_SOCKET );
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_SSL_ENABLE_CALLBACK )( LBER_SOCKET );
|
||||
|
||||
|
||||
/*
|
||||
* structure to hold I/O function pointers
|
||||
*/
|
||||
struct ldap_io_fns {
|
||||
LDAP_IOF_READ_CALLBACK *liof_read;
|
||||
LDAP_IOF_WRITE_CALLBACK *liof_write;
|
||||
LDAP_IOF_SELECT_CALLBACK *liof_select;
|
||||
LDAP_IOF_SOCKET_CALLBACK *liof_socket;
|
||||
LDAP_IOF_IOCTL_CALLBACK *liof_ioctl;
|
||||
LDAP_IOF_CONNECT_CALLBACK *liof_connect;
|
||||
LDAP_IOF_CLOSE_CALLBACK *liof_close;
|
||||
LDAP_IOF_SSL_ENABLE_CALLBACK *liof_ssl_enable;
|
||||
};
|
||||
|
||||
/*
|
||||
* structure for holding ldapv3 controls
|
||||
*/
|
||||
typedef struct ldapcontrol {
|
||||
char *ldctl_oid;
|
||||
struct berval ldctl_value;
|
||||
char ldctl_iscritical;
|
||||
} LDAPControl, *PLDAPControl;
|
||||
|
||||
/*
|
||||
* structure for ldap friendly mapping routines
|
||||
*/
|
||||
|
||||
typedef struct friendly {
|
||||
char *f_unfriendly;
|
||||
char *f_friendly;
|
||||
} *FriendlyMap;
|
||||
|
||||
/*
|
||||
* structure for a sort-key
|
||||
*/
|
||||
|
||||
typedef struct LDAPsortkey {
|
||||
char * sk_attrtype;
|
||||
char * sk_matchruleoid;
|
||||
int sk_reverseorder;
|
||||
} LDAPsortkey;
|
||||
|
||||
/*
|
||||
* structures for ldap getfilter routines
|
||||
*/
|
||||
|
||||
typedef struct ldap_filt_info {
|
||||
char *lfi_filter;
|
||||
char *lfi_desc;
|
||||
int lfi_scope; /* LDAP_SCOPE_BASE, etc */
|
||||
int lfi_isexact; /* exact match filter? */
|
||||
struct ldap_filt_info *lfi_next;
|
||||
} LDAPFiltInfo;
|
||||
|
||||
#define LDAP_FILT_MAXSIZ 1024
|
||||
|
||||
typedef struct ldap_filt_list LDAPFiltList; /* opaque filter list handle */
|
||||
typedef struct ldap_filt_desc LDAPFiltDesc; /* opaque filter desc handle */
|
||||
|
||||
/*
|
||||
* structure that describes a VirtualListViewRequest control.
|
||||
* note that ldvlist_index and ldvlist_size are only relevant to
|
||||
* ldap_create_virtuallist_control() if ldvlist_attrvalue is NULL.
|
||||
*/
|
||||
typedef struct ldapvirtuallist {
|
||||
unsigned long ldvlist_before_count; /* # entries before target */
|
||||
unsigned long ldvlist_after_count; /* # entries after target */
|
||||
char *ldvlist_attrvalue; /* jump to this value */
|
||||
unsigned long ldvlist_index; /* list offset */
|
||||
unsigned long ldvlist_size; /* number of items in vlist */
|
||||
void *ldvlist_extradata; /* for use by application */
|
||||
} LDAPVirtualList;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* types for ldap URL handling
|
||||
*/
|
||||
typedef struct ldap_url_desc {
|
||||
char *lud_host;
|
||||
int lud_port;
|
||||
char *lud_dn;
|
||||
char **lud_attrs;
|
||||
int lud_scope;
|
||||
char *lud_filter;
|
||||
unsigned long lud_options;
|
||||
#define LDAP_URL_OPT_SECURE 0x01
|
||||
char *lud_string; /* for internal use only */
|
||||
} LDAPURLDesc;
|
||||
#define NULLLDAPURLDESC ((LDAPURLDesc *)NULL)
|
||||
|
||||
/* Version reporting */
|
||||
typedef struct _LDAPVersion {
|
||||
int sdk_version; /* Version of the SDK, * 100 */
|
||||
int protocol_version; /* Highest protocol version
|
||||
supported by the SDK, * 100 */
|
||||
int SSL_version; /* SSL version if this SDK
|
||||
version supports it, * 100 */
|
||||
int security_level; /* highest level available */
|
||||
int reserved[4];
|
||||
} LDAPVersion;
|
||||
#define LDAP_SECURITY_NONE 0
|
||||
|
||||
#define LDAP_URL_ERR_NOTLDAP 1 /* URL doesn't begin with "ldap://" */
|
||||
#define LDAP_URL_ERR_NODN 2 /* URL has no DN (required) */
|
||||
#define LDAP_URL_ERR_BADSCOPE 3 /* URL scope string is invalid */
|
||||
#define LDAP_URL_ERR_MEM 4 /* can't allocate memory space */
|
||||
#define LDAP_URL_ERR_PARAM 5 /* bad parameter to an URL function */
|
||||
|
||||
/* possible result types a server can return */
|
||||
#define LDAP_RES_BIND 0x61L /* 97 */
|
||||
#define LDAP_RES_SEARCH_ENTRY 0x64L /* 100 */
|
||||
#define LDAP_RES_SEARCH_RESULT 0x65L /* 101 */
|
||||
#define LDAP_RES_MODIFY 0x67L /* 103 */
|
||||
#define LDAP_RES_ADD 0x69L /* 105 */
|
||||
#define LDAP_RES_DELETE 0x6bL /* 107 */
|
||||
#define LDAP_RES_MODRDN 0x6dL /* 109 */
|
||||
#define LDAP_RES_RENAME 0x6dL /* same as LDAP_RES_MODRDN */
|
||||
#define LDAP_RES_COMPARE 0x6fL /* 111 */
|
||||
#define LDAP_RES_SEARCH_REFERENCE 0x73L /* 115 */
|
||||
#define LDAP_RES_EXTENDED 0x78L /* 120 */
|
||||
#define LDAP_RES_ANY (-1L)
|
||||
|
||||
/* authentication methods available */
|
||||
#define LDAP_AUTH_NONE 0x00L
|
||||
#define LDAP_AUTH_SIMPLE 0x80L
|
||||
#define LDAP_AUTH_SASL 0xa3L
|
||||
|
||||
/* supported SASL methods */
|
||||
#define LDAP_SASL_SIMPLE 0 /* special value used for simple bind */
|
||||
#define LDAP_SASL_EXTERNAL "EXTERNAL"
|
||||
|
||||
|
||||
/* search scopes */
|
||||
#define LDAP_SCOPE_BASE 0x00
|
||||
#define LDAP_SCOPE_ONELEVEL 0x01
|
||||
#define LDAP_SCOPE_SUBTREE 0x02
|
||||
|
||||
/* alias dereferencing */
|
||||
#define LDAP_DEREF_NEVER 0
|
||||
#define LDAP_DEREF_SEARCHING 1
|
||||
#define LDAP_DEREF_FINDING 2
|
||||
#define LDAP_DEREF_ALWAYS 3
|
||||
|
||||
/* size/time limits */
|
||||
#define LDAP_NO_LIMIT 0
|
||||
|
||||
/* allowed values for "all" ldap_result() parameter */
|
||||
#define LDAP_MSG_ONE 0
|
||||
#define LDAP_MSG_ALL 1
|
||||
#define LDAP_MSG_RECEIVED 2
|
||||
|
||||
/* possible error codes we can be returned */
|
||||
#define LDAP_SUCCESS 0x00 /* 0 */
|
||||
#define LDAP_OPERATIONS_ERROR 0x01 /* 1 */
|
||||
#define LDAP_PROTOCOL_ERROR 0x02 /* 2 */
|
||||
#define LDAP_TIMELIMIT_EXCEEDED 0x03 /* 3 */
|
||||
#define LDAP_SIZELIMIT_EXCEEDED 0x04 /* 4 */
|
||||
#define LDAP_COMPARE_FALSE 0x05 /* 5 */
|
||||
#define LDAP_COMPARE_TRUE 0x06 /* 6 */
|
||||
#define LDAP_AUTH_METHOD_NOT_SUPPORTED 0x07 /* 7 */
|
||||
#define LDAP_STRONG_AUTH_NOT_SUPPORTED LDAP_AUTH_METHOD_NOT_SUPPORTED
|
||||
#define LDAP_STRONG_AUTH_REQUIRED 0x08 /* 8 */
|
||||
#define LDAP_PARTIAL_RESULTS 0x09 /* 9 (UMich LDAPv2 extn) */
|
||||
#define LDAP_REFERRAL 0x0a /* 10 - LDAPv3 */
|
||||
#define LDAP_ADMINLIMIT_EXCEEDED 0x0b /* 11 - LDAPv3 */
|
||||
#define LDAP_UNAVAILABLE_CRITICAL_EXTENSION 0x0c /* 12 - LDAPv3 */
|
||||
#define LDAP_CONFIDENTIALITY_REQUIRED 0x0d /* 13 */
|
||||
#define LDAP_SASL_BIND_IN_PROGRESS 0x0e /* 14 - LDAPv3 */
|
||||
|
||||
#define LDAP_NO_SUCH_ATTRIBUTE 0x10 /* 16 */
|
||||
#define LDAP_UNDEFINED_TYPE 0x11 /* 17 */
|
||||
#define LDAP_INAPPROPRIATE_MATCHING 0x12 /* 18 */
|
||||
#define LDAP_CONSTRAINT_VIOLATION 0x13 /* 19 */
|
||||
#define LDAP_TYPE_OR_VALUE_EXISTS 0x14 /* 20 */
|
||||
#define LDAP_INVALID_SYNTAX 0x15 /* 21 */
|
||||
|
||||
#define LDAP_NO_SUCH_OBJECT 0x20 /* 32 */
|
||||
#define LDAP_ALIAS_PROBLEM 0x21 /* 33 */
|
||||
#define LDAP_INVALID_DN_SYNTAX 0x22 /* 34 */
|
||||
#define LDAP_IS_LEAF 0x23 /* 35 (not used in LDAPv3) */
|
||||
#define LDAP_ALIAS_DEREF_PROBLEM 0x24 /* 36 */
|
||||
|
||||
#define NAME_ERROR(n) ((n & 0xf0) == 0x20)
|
||||
|
||||
#define LDAP_INAPPROPRIATE_AUTH 0x30 /* 48 */
|
||||
#define LDAP_INVALID_CREDENTIALS 0x31 /* 49 */
|
||||
#define LDAP_INSUFFICIENT_ACCESS 0x32 /* 50 */
|
||||
#define LDAP_BUSY 0x33 /* 51 */
|
||||
#define LDAP_UNAVAILABLE 0x34 /* 52 */
|
||||
#define LDAP_UNWILLING_TO_PERFORM 0x35 /* 53 */
|
||||
#define LDAP_LOOP_DETECT 0x36 /* 54 */
|
||||
|
||||
#define LDAP_SORT_CONTROL_MISSING 0x3C /* 60 */
|
||||
|
||||
#define LDAP_NAMING_VIOLATION 0x40 /* 64 */
|
||||
#define LDAP_OBJECT_CLASS_VIOLATION 0x41 /* 65 */
|
||||
#define LDAP_NOT_ALLOWED_ON_NONLEAF 0x42 /* 66 */
|
||||
#define LDAP_NOT_ALLOWED_ON_RDN 0x43 /* 67 */
|
||||
#define LDAP_ALREADY_EXISTS 0x44 /* 68 */
|
||||
#define LDAP_NO_OBJECT_CLASS_MODS 0x45 /* 69 */
|
||||
#define LDAP_RESULTS_TOO_LARGE 0x46 /* 70 - CLDAP */
|
||||
#define LDAP_AFFECTS_MULTIPLE_DSAS 0x47 /* 71 */
|
||||
|
||||
#define LDAP_OTHER 0x50 /* 80 */
|
||||
#define LDAP_SERVER_DOWN 0x51 /* 81 */
|
||||
#define LDAP_LOCAL_ERROR 0x52 /* 82 */
|
||||
#define LDAP_ENCODING_ERROR 0x53 /* 83 */
|
||||
#define LDAP_DECODING_ERROR 0x54 /* 84 */
|
||||
#define LDAP_TIMEOUT 0x55 /* 85 */
|
||||
#define LDAP_AUTH_UNKNOWN 0x56 /* 86 */
|
||||
#define LDAP_FILTER_ERROR 0x57 /* 87 */
|
||||
#define LDAP_USER_CANCELLED 0x58 /* 88 */
|
||||
#define LDAP_PARAM_ERROR 0x59 /* 89 */
|
||||
#define LDAP_NO_MEMORY 0x5a /* 90 */
|
||||
#define LDAP_CONNECT_ERROR 0x5b /* 91 */
|
||||
#define LDAP_NOT_SUPPORTED 0x5c /* 92 - LDAPv3 */
|
||||
#define LDAP_CONTROL_NOT_FOUND 0x5d /* 93 - LDAPv3 */
|
||||
#define LDAP_NO_RESULTS_RETURNED 0x5e /* 94 - LDAPv3 */
|
||||
#define LDAP_MORE_RESULTS_TO_RETURN 0x5f /* 95 - LDAPv3 */
|
||||
#define LDAP_CLIENT_LOOP 0x60 /* 96 - LDAPv3 */
|
||||
#define LDAP_REFERRAL_LIMIT_EXCEEDED 0x61 /* 97 - LDAPv3 */
|
||||
|
||||
/*
|
||||
* LDAPv3 server controls we know about
|
||||
*/
|
||||
#define LDAP_CONTROL_MANAGEDSAIT "2.16.840.1.113730.3.4.2"
|
||||
#define LDAP_CONTROL_SORTREQUEST "1.2.840.113556.1.4.473"
|
||||
#define LDAP_CONTROL_SORTRESPONSE "1.2.840.113556.1.4.474"
|
||||
#define LDAP_CONTROL_PERSISTENTSEARCH "2.16.840.1.113730.3.4.3"
|
||||
#define LDAP_CONTROL_ENTRYCHANGE "2.16.840.1.113730.3.4.7"
|
||||
#define LDAP_CONTROL_VLVREQUEST "2.16.840.1.113730.3.4.9"
|
||||
#define LDAP_CONTROL_VLVRESPONSE "2.16.840.1.113730.3.4.10"
|
||||
/* Password information sent back to client */
|
||||
#define LDAP_CONTROL_PWEXPIRED "2.16.840.1.113730.3.4.4"
|
||||
#define LDAP_CONTROL_PWEXPIRING "2.16.840.1.113730.3.4.5"
|
||||
|
||||
/*
|
||||
* Client controls we know about
|
||||
*/
|
||||
#define LDAP_CONTROL_REFERRALS "1.2.840.113556.1.4.616"
|
||||
|
||||
/* function prototypes for ldap library */
|
||||
#ifndef LDAP_API
|
||||
#if defined( _WINDOWS ) || defined( _WIN32 )
|
||||
#define LDAP_API(rt) rt
|
||||
#else /* _WINDOWS */
|
||||
#define LDAP_API(rt) rt
|
||||
#endif /* _WINDOWS */
|
||||
#endif /* LDAP_API */
|
||||
|
||||
typedef int (LDAP_CALL LDAP_CALLBACK LDAP_REBINDPROC_CALLBACK)( LDAP *ld,
|
||||
char **dnp, char **passwdp, int *authmethodp, int freeit, void *arg);
|
||||
|
||||
typedef const struct berval* (LDAP_C LDAP_CALLBACK
|
||||
LDAP_KEYGEN_CALLBACK)( void *arg, LDAP *ld, LDAPMessage *entry );
|
||||
typedef int (LDAP_C LDAP_CALLBACK
|
||||
LDAP_KEYCMP_CALLBACK)( void *arg, const struct berval*, const struct berval* );
|
||||
typedef void (LDAP_C LDAP_CALLBACK
|
||||
LDAP_KEYFREE_CALLBACK)( void *arg, const struct berval* );
|
||||
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_CMP_CALLBACK)(const char*,
|
||||
const char*);
|
||||
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_VALCMP_CALLBACK)(const char**,
|
||||
const char**);
|
||||
|
||||
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_CANCELPROC_CALLBACK)( void *cl );
|
||||
|
||||
LDAP_API(LDAP *) LDAP_CALL ldap_open( const char *host, int port );
|
||||
LDAP_API(LDAP *) LDAP_CALL ldap_init( const char *defhost, int defport );
|
||||
LDAP_API(int) LDAP_CALL ldap_set_option( LDAP *ld, int option, void *optdata );
|
||||
LDAP_API(int) LDAP_CALL ldap_get_option( LDAP *ld, int option, void *optdata );
|
||||
LDAP_API(int) LDAP_CALL ldap_unbind( LDAP *ld );
|
||||
LDAP_API(int) LDAP_CALL ldap_unbind_s( LDAP *ld );
|
||||
LDAP_API(int) LDAP_CALL ldap_version( LDAPVersion *ver );
|
||||
|
||||
/*
|
||||
* perform ldap operations and obtain results
|
||||
*/
|
||||
LDAP_API(int) LDAP_CALL ldap_abandon( LDAP *ld, int msgid );
|
||||
LDAP_API(int) LDAP_CALL ldap_add( LDAP *ld, const char *dn, LDAPMod **attrs );
|
||||
LDAP_API(int) LDAP_CALL ldap_add_s( LDAP *ld, const char *dn, LDAPMod **attrs );
|
||||
LDAP_API(void) LDAP_CALL ldap_set_rebind_proc( LDAP *ld,
|
||||
LDAP_REBINDPROC_CALLBACK *rebindproc, void *arg );
|
||||
LDAP_API(int) LDAP_CALL ldap_simple_bind( LDAP *ld, const char *who,
|
||||
const char *passwd );
|
||||
LDAP_API(int) LDAP_CALL ldap_simple_bind_s( LDAP *ld, const char *who,
|
||||
const char *passwd );
|
||||
LDAP_API(int) LDAP_CALL ldap_modify( LDAP *ld, const char *dn, LDAPMod **mods );
|
||||
LDAP_API(int) LDAP_CALL ldap_modify_s( LDAP *ld, const char *dn,
|
||||
LDAPMod **mods );
|
||||
LDAP_API(int) LDAP_CALL ldap_modrdn( LDAP *ld, const char *dn,
|
||||
const char *newrdn );
|
||||
LDAP_API(int) LDAP_CALL ldap_modrdn_s( LDAP *ld, const char *dn,
|
||||
const char *newrdn );
|
||||
LDAP_API(int) LDAP_CALL ldap_modrdn2( LDAP *ld, const char *dn,
|
||||
const char *newrdn, int deleteoldrdn );
|
||||
LDAP_API(int) LDAP_CALL ldap_modrdn2_s( LDAP *ld, const char *dn,
|
||||
const char *newrdn, int deleteoldrdn);
|
||||
LDAP_API(int) LDAP_CALL ldap_compare( LDAP *ld, const char *dn,
|
||||
const char *attr, const char *value );
|
||||
LDAP_API(int) LDAP_CALL ldap_compare_s( LDAP *ld, const char *dn,
|
||||
const char *attr, const char *value );
|
||||
LDAP_API(int) LDAP_CALL ldap_delete( LDAP *ld, const char *dn );
|
||||
LDAP_API(int) LDAP_CALL ldap_delete_s( LDAP *ld, const char *dn );
|
||||
LDAP_API(int) LDAP_CALL ldap_search( LDAP *ld, const char *base, int scope,
|
||||
const char *filter, char **attrs, int attrsonly );
|
||||
LDAP_API(int) LDAP_CALL ldap_search_s( LDAP *ld, const char *base, int scope,
|
||||
const char *filter, char **attrs, int attrsonly, LDAPMessage **res );
|
||||
LDAP_API(int) LDAP_CALL ldap_search_st( LDAP *ld, const char *base, int scope,
|
||||
const char *filter, char **attrs, int attrsonly,
|
||||
struct timeval *timeout, LDAPMessage **res );
|
||||
LDAP_API(int) LDAP_CALL ldap_result( LDAP *ld, int msgid, int all,
|
||||
struct timeval *timeout, LDAPMessage **result );
|
||||
LDAP_API(int) LDAP_CALL ldap_msgfree( LDAPMessage *lm );
|
||||
LDAP_API(void) LDAP_CALL ldap_mods_free( LDAPMod **mods, int freemods );
|
||||
LDAP_API(int) LDAP_CALL ldap_msgid( LDAPMessage *lm );
|
||||
LDAP_API(int) LDAP_CALL ldap_msgtype( LDAPMessage *lm );
|
||||
|
||||
/*
|
||||
* parse/create controls
|
||||
*/
|
||||
LDAP_API(int) LDAP_CALL ldap_create_sort_control( LDAP *ld,
|
||||
LDAPsortkey **sortKeyList, const char ctl_iscritical,
|
||||
LDAPControl **ctrlp );
|
||||
LDAP_API(int) LDAP_CALL ldap_parse_sort_control( LDAP *ld,
|
||||
LDAPControl **ctrls, unsigned long *result, char **attribute );
|
||||
LDAP_API(int) LDAP_CALL ldap_controls_count( LDAPControl **ctrls );
|
||||
|
||||
/*
|
||||
* parse/deal with results and errors returned
|
||||
*/
|
||||
LDAP_API(int) LDAP_CALL ldap_get_lderrno( LDAP *ld, char **m, char **s );
|
||||
LDAP_API(int) LDAP_CALL ldap_set_lderrno( LDAP *ld, int e, char *m, char *s );
|
||||
LDAP_API(int) LDAP_CALL ldap_result2error( LDAP *ld, LDAPMessage *r,
|
||||
int freeit );
|
||||
LDAP_API(char *) LDAP_CALL ldap_err2string( int err );
|
||||
LDAP_API(void) LDAP_CALL ldap_perror( LDAP *ld, const char *s );
|
||||
LDAP_API(LDAPMessage *) LDAP_CALL ldap_first_entry( LDAP *ld,
|
||||
LDAPMessage *chain );
|
||||
LDAP_API(LDAPMessage *) LDAP_CALL ldap_next_entry( LDAP *ld,
|
||||
LDAPMessage *entry );
|
||||
LDAP_API(int) LDAP_CALL ldap_count_entries( LDAP *ld, LDAPMessage *chain );
|
||||
LDAP_API(char *) LDAP_CALL ldap_get_dn( LDAP *ld, LDAPMessage *entry );
|
||||
LDAP_API(char *) LDAP_CALL ldap_dn2ufn( const char *dn );
|
||||
LDAP_API(char **) LDAP_CALL ldap_explode_dn( const char *dn,
|
||||
const int notypes );
|
||||
LDAP_API(char **) LDAP_CALL ldap_explode_rdn( const char *dn,
|
||||
const int notypes );
|
||||
LDAP_API(char **) LDAP_CALL ldap_explode_dns( const char *dn );
|
||||
LDAP_API(char *) LDAP_CALL ldap_first_attribute( LDAP *ld, LDAPMessage *entry,
|
||||
BerElement **ber );
|
||||
LDAP_API(char *) LDAP_CALL ldap_next_attribute( LDAP *ld, LDAPMessage *entry,
|
||||
BerElement *ber );
|
||||
LDAP_API(void) LDAP_CALL ldap_ber_free( BerElement *ber, int freebuf );
|
||||
LDAP_API(char **) LDAP_CALL ldap_get_values( LDAP *ld, LDAPMessage *entry,
|
||||
const char *target );
|
||||
LDAP_API(struct berval **) LDAP_CALL ldap_get_values_len( LDAP *ld,
|
||||
LDAPMessage *entry, const char *target );
|
||||
LDAP_API(char **) LDAP_CALL ldap_get_lang_values( LDAP *ld, LDAPMessage *entry,
|
||||
const char *target, char **type );
|
||||
LDAP_API(struct berval **) LDAP_CALL ldap_get_lang_values_len( LDAP *ld,
|
||||
LDAPMessage *entry, const char *target, char **type );
|
||||
LDAP_API(int) LDAP_CALL ldap_count_values( char **vals );
|
||||
LDAP_API(int) LDAP_CALL ldap_count_values_len( struct berval **vals );
|
||||
LDAP_API(void) LDAP_CALL ldap_value_free( char **vals );
|
||||
LDAP_API(void) LDAP_CALL ldap_value_free_len( struct berval **vals );
|
||||
LDAP_API(void) LDAP_CALL ldap_memfree( void *p );
|
||||
|
||||
/*
|
||||
* LDAPv3 extended operation calls
|
||||
*/
|
||||
/*
|
||||
* Note: all of the new asynchronous calls return an LDAP error code,
|
||||
* not a message id. A message id is returned via the int *msgidp
|
||||
* parameter (usually the last parameter) if appropriate.
|
||||
*/
|
||||
LDAP_API(int) LDAP_CALL ldap_abandon_ext( LDAP *ld, int msgid,
|
||||
LDAPControl **serverctrls, LDAPControl **clientctrls );
|
||||
LDAP_API(int) LDAP_CALL ldap_add_ext( LDAP *ld, const char *dn, LDAPMod **attrs,
|
||||
LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp );
|
||||
LDAP_API(int) LDAP_CALL ldap_add_ext_s( LDAP *ld, const char *dn,
|
||||
LDAPMod **attrs, LDAPControl **serverctrls, LDAPControl **clientctrls );
|
||||
LDAP_API(int) LDAP_CALL ldap_sasl_bind( LDAP *ld, const char *dn,
|
||||
const char *mechanism, struct berval *cred, LDAPControl **serverctrls,
|
||||
LDAPControl **clientctrls, int *msgidp );
|
||||
LDAP_API(int) LDAP_CALL ldap_sasl_bind_s( LDAP *ld, const char *dn,
|
||||
const char *mechanism, struct berval *cred, LDAPControl **serverctrls,
|
||||
LDAPControl **clientctrls, struct berval **servercredp );
|
||||
LDAP_API(int) LDAP_CALL ldap_modify_ext( LDAP *ld, const char *dn,
|
||||
LDAPMod **mods, LDAPControl **serverctrls, LDAPControl **clientctrls,
|
||||
int *msgidp );
|
||||
LDAP_API(int) LDAP_CALL ldap_modify_ext_s( LDAP *ld, const char *dn,
|
||||
LDAPMod **mods, LDAPControl **serverctrls, LDAPControl **clientctrls );
|
||||
LDAP_API(int) LDAP_CALL ldap_rename( LDAP *ld, const char *dn,
|
||||
const char *newrdn, const char *newparent, int deleteoldrdn,
|
||||
LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp );
|
||||
LDAP_API(int) LDAP_CALL ldap_rename_s( LDAP *ld, const char *dn,
|
||||
const char *newrdn, const char *newparent, int deleteoldrdn,
|
||||
LDAPControl **serverctrls, LDAPControl **clientctrls );
|
||||
LDAP_API(int) LDAP_CALL ldap_compare_ext( LDAP *ld, const char *dn,
|
||||
const char *attr, struct berval *bvalue, LDAPControl **serverctrls,
|
||||
LDAPControl **clientctrls, int *msgidp );
|
||||
LDAP_API(int) LDAP_CALL ldap_compare_ext_s( LDAP *ld, const char *dn,
|
||||
const char *attr, struct berval *bvalue, LDAPControl **serverctrls,
|
||||
LDAPControl **clientctrls );
|
||||
LDAP_API(int) LDAP_CALL ldap_delete_ext( LDAP *ld, const char *dn,
|
||||
LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp );
|
||||
LDAP_API(int) LDAP_CALL ldap_delete_ext_s( LDAP *ld, const char *dn,
|
||||
LDAPControl **serverctrls, LDAPControl **clientctrls );
|
||||
LDAP_API(int) LDAP_CALL ldap_search_ext( LDAP *ld, const char *base,
|
||||
int scope, const char *filter, char **attrs, int attrsonly,
|
||||
LDAPControl **serverctrls, LDAPControl **clientctrls,
|
||||
struct timeval *timeoutp, int sizelimit, int *msgidp );
|
||||
LDAP_API(int) LDAP_CALL ldap_search_ext_s( LDAP *ld, const char *base,
|
||||
int scope, const char *filter, char **attrs, int attrsonly,
|
||||
LDAPControl **serverctrls, LDAPControl **clientctrls,
|
||||
struct timeval *timeoutp, int sizelimit, LDAPMessage **res );
|
||||
LDAP_API(int) LDAP_CALL ldap_extended_operation( LDAP *ld,
|
||||
const char *requestoid, struct berval *requestdata,
|
||||
LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp );
|
||||
LDAP_API(int) LDAP_CALL ldap_extended_operation_s( LDAP *ld,
|
||||
const char *requestoid, struct berval *requestdata,
|
||||
LDAPControl **serverctrls, LDAPControl **clientctrls,
|
||||
char **retoidp, struct berval **retdatap );
|
||||
|
||||
/*
|
||||
* Routines for manipulating sort key lists, used for making sort controls
|
||||
*/
|
||||
|
||||
LDAP_API(void) LDAP_CALL ldap_free_sort_keylist (LDAPsortkey **sortKeyList);
|
||||
LDAP_API(int) LDAP_CALL ldap_create_sort_keylist (LDAPsortkey ***sortKeyList,char *string_rep);
|
||||
|
||||
|
||||
/*
|
||||
* LDAPv3 extended parsing / result handling calls
|
||||
*/
|
||||
LDAP_API(int) LDAP_CALL ldap_parse_sasl_bind_result( LDAP *ld,
|
||||
LDAPMessage *res, struct berval **servercredp, int freeit );
|
||||
LDAP_API(int) LDAP_CALL ldap_parse_result( LDAP *ld, LDAPMessage *res,
|
||||
int *errcodep, char **matcheddnp, char **errmsgp, char ***referralsp,
|
||||
LDAPControl ***serverctrlsp, int freeit );
|
||||
LDAP_API(int) LDAP_CALL ldap_parse_extended_result( LDAP *ld, LDAPMessage *res,
|
||||
char **retoidp, struct berval **retdatap, int freeit );
|
||||
LDAP_API(LDAPMessage *) LDAP_CALL ldap_first_message( LDAP *ld,
|
||||
LDAPMessage *res );
|
||||
LDAP_API(LDAPMessage *) LDAP_CALL ldap_next_message( LDAP *ld,
|
||||
LDAPMessage *msg );
|
||||
LDAP_API(int) LDAP_CALL ldap_count_messages( LDAP *ld, LDAPMessage *res );
|
||||
LDAP_API(LDAPMessage *) LDAP_CALL ldap_first_reference( LDAP *ld,
|
||||
LDAPMessage *res );
|
||||
LDAP_API(LDAPMessage *) LDAP_CALL ldap_next_reference( LDAP *ld,
|
||||
LDAPMessage *ref );
|
||||
LDAP_API(int) LDAP_CALL ldap_count_references( LDAP *ld, LDAPMessage *res );
|
||||
LDAP_API(int) LDAP_CALL ldap_parse_reference( LDAP *ld, LDAPMessage *ref,
|
||||
char ***referralsp, LDAPControl ***serverctrlsp, int freeit );
|
||||
LDAP_API(int) LDAP_CALL ldap_get_entry_controls( LDAP *ld, LDAPMessage *entry,
|
||||
LDAPControl ***serverctrlsp );
|
||||
LDAP_API(void) LDAP_CALL ldap_control_free( LDAPControl *ctrl );
|
||||
LDAP_API(void) LDAP_CALL ldap_controls_free( LDAPControl **ctrls );
|
||||
|
||||
/*
|
||||
* virtual list view support
|
||||
*/
|
||||
|
||||
LDAP_API(int) LDAP_CALL ldap_create_virtuallist_control( LDAP *ld,
|
||||
LDAPVirtualList *ldvlistp, LDAPControl **ctrlp );
|
||||
|
||||
LDAP_API(int) LDAP_CALL ldap_parse_virtuallist_control( LDAP *ld,
|
||||
LDAPControl **ctrls, unsigned long *target_posp,
|
||||
unsigned long *list_sizep, int *errcodep );
|
||||
|
||||
/*
|
||||
* entry sorting routines
|
||||
*/
|
||||
LDAP_API(int) LDAP_CALL ldap_keysort_entries( LDAP *ld, LDAPMessage **chain,
|
||||
void *arg, LDAP_KEYGEN_CALLBACK *gen, LDAP_KEYCMP_CALLBACK *cmp, LDAP_KEYFREE_CALLBACK *fre);
|
||||
LDAP_API(int) LDAP_CALL ldap_multisort_entries( LDAP *ld, LDAPMessage **chain,
|
||||
char **attr, LDAP_CMP_CALLBACK *cmp);
|
||||
LDAP_API(int) LDAP_CALL ldap_sort_entries( LDAP *ld, LDAPMessage **chain,
|
||||
char *attr, LDAP_CMP_CALLBACK *cmp);
|
||||
LDAP_API(int) LDAP_CALL ldap_sort_values( LDAP *ld, char **vals,
|
||||
LDAP_VALCMP_CALLBACK *cmp);
|
||||
LDAP_API(int) LDAP_C LDAP_CALLBACK ldap_sort_strcasecmp( const char **a,
|
||||
const char **b );
|
||||
|
||||
/*
|
||||
* getfilter routines
|
||||
*/
|
||||
LDAP_API(LDAPFiltDesc *) LDAP_CALL ldap_init_getfilter( char *fname );
|
||||
LDAP_API(LDAPFiltDesc *) LDAP_CALL ldap_init_getfilter_buf( char *buf,
|
||||
long buflen );
|
||||
LDAP_API(LDAPFiltInfo *) LDAP_CALL ldap_getfirstfilter( LDAPFiltDesc *lfdp,
|
||||
char *tagpat, char *value );
|
||||
LDAP_API(LDAPFiltInfo *) LDAP_CALL ldap_getnextfilter( LDAPFiltDesc *lfdp );
|
||||
LDAP_API(int) LDAP_CALL ldap_set_filter_additions( LDAPFiltDesc *lfdp,
|
||||
char *prefix, char *suffix );
|
||||
LDAP_API(int) LDAP_CALL ldap_create_filter( char *buf, unsigned long buflen,
|
||||
char *pattern, char *prefix, char *suffix, char *attr,
|
||||
char *value, char **valwords );
|
||||
LDAP_API(void) LDAP_CALL ldap_getfilter_free( LDAPFiltDesc *lfdp );
|
||||
|
||||
/*
|
||||
* friendly routines
|
||||
*/
|
||||
LDAP_API(char *) LDAP_CALL ldap_friendly_name( char *filename, char *name,
|
||||
FriendlyMap *map );
|
||||
LDAP_API(void) LDAP_CALL ldap_free_friendlymap( FriendlyMap *map );
|
||||
|
||||
/*
|
||||
* ldap url routines
|
||||
*/
|
||||
LDAP_API(int) LDAP_CALL ldap_is_ldap_url( char *url );
|
||||
LDAP_API(int) LDAP_CALL ldap_url_parse( char *url, LDAPURLDesc **ludpp );
|
||||
LDAP_API(void) LDAP_CALL ldap_free_urldesc( LDAPURLDesc *ludp );
|
||||
LDAP_API(int) LDAP_CALL ldap_url_search( LDAP *ld, char *url, int attrsonly );
|
||||
LDAP_API(int) LDAP_CALL ldap_url_search_s( LDAP *ld, char *url, int attrsonly,
|
||||
LDAPMessage **res );
|
||||
LDAP_API(int) LDAP_CALL ldap_url_search_st( LDAP *ld, char *url, int attrsonly,
|
||||
struct timeval *timeout, LDAPMessage **res );
|
||||
|
||||
/*
|
||||
* routines for creating persistent search controls and for handling
|
||||
* "entry changed notification" controls (an LDAPv3 extension).
|
||||
*/
|
||||
#define LDAP_CHANGETYPE_ADD 1
|
||||
#define LDAP_CHANGETYPE_DELETE 2
|
||||
#define LDAP_CHANGETYPE_MODIFY 4
|
||||
#define LDAP_CHANGETYPE_MODDN 8
|
||||
#define LDAP_CHANGETYPE_ANY (1|2|4|8)
|
||||
LDAP_API(int) LDAP_CALL ldap_create_persistentsearch_control( LDAP *ld,
|
||||
int changetypes, int changesonly, int return_echg_ctls,
|
||||
char ctl_iscritical, LDAPControl **ctrlp );
|
||||
LDAP_API(int) LDAP_CALL ldap_parse_entrychange_control( LDAP *ld,
|
||||
LDAPControl **ctrls, int *chgtypep, char **prevdnp,
|
||||
int *chgnumpresentp, long *chgnump );
|
||||
|
||||
typedef struct ldapmemcache LDAPMemCache; /* opaque in-memory cache handle */
|
||||
|
||||
/*
|
||||
* cacheing routines
|
||||
*/
|
||||
LDAP_API(int) LDAP_CALL ldap_memcache_init( unsigned long ttl,
|
||||
unsigned long size, char **baseDNs, struct ldap_thread_fns *thread_fns,
|
||||
LDAPMemCache **cachep );
|
||||
LDAP_API(int) LDAP_CALL ldap_memcache_set( LDAP *ld, LDAPMemCache *cache );
|
||||
LDAP_API(int) LDAP_CALL ldap_memcache_get( LDAP *ld, LDAPMemCache **cachep );
|
||||
LDAP_API(void) LDAP_CALL ldap_memcache_flush( LDAPMemCache *cache, char *dn,
|
||||
int scope );
|
||||
LDAP_API(void) LDAP_CALL ldap_memcache_destroy( LDAPMemCache *cache );
|
||||
LDAP_API(void) LDAP_CALL ldap_memcache_update( LDAPMemCache *cache );
|
||||
|
||||
|
||||
/*
|
||||
* DNS resolver callbacks. for now, we only use gethostbyname()
|
||||
*/
|
||||
typedef struct LDAPHostEnt {
|
||||
char *ldaphe_name; /* official name of host */
|
||||
char **ldaphe_aliases; /* alias list */
|
||||
int ldaphe_addrtype; /* host address type */
|
||||
int ldaphe_length; /* length of address */
|
||||
char **ldaphe_addr_list; /* list of addresses from name server */
|
||||
} LDAPHostEnt;
|
||||
|
||||
typedef LDAPHostEnt * (LDAP_C LDAP_CALLBACK LDAP_DNSFN_GETHOSTBYNAME)(
|
||||
const char *name, LDAPHostEnt *result, char *buffer,
|
||||
int buflen, int *statusp, void *extradata );
|
||||
typedef LDAPHostEnt * (LDAP_C LDAP_CALLBACK LDAP_DNSFN_GETHOSTBYADDR)(
|
||||
const char *addr, int length, int type, LDAPHostEnt *result,
|
||||
char *buffer, int buflen, int *statusp, void *extradata );
|
||||
|
||||
struct ldap_dns_fns {
|
||||
void *lddnsfn_extradata;
|
||||
int lddnsfn_bufsize;
|
||||
LDAP_DNSFN_GETHOSTBYNAME *lddnsfn_gethostbyname;
|
||||
LDAP_DNSFN_GETHOSTBYADDR *lddnsfn_gethostbyaddr;
|
||||
};
|
||||
|
||||
#define LDAP_OPT_DNS_FN_PTRS 96 /* Netscape extension */
|
||||
|
||||
/************** the functions in this section are experimental ***************/
|
||||
|
||||
/*
|
||||
* libldap memory allocation callback functions. These are global and can
|
||||
* not be set on a per-LDAP session handle basis. Install your own
|
||||
* functions by making a call like this:
|
||||
* ldap_set_option( NULL, LDAP_OPT_MEMALLOC_FN_PTRS, &memalloc_fns );
|
||||
*
|
||||
* look in lber.h for the function typedefs themselves.
|
||||
*/
|
||||
struct ldap_memalloc_fns {
|
||||
LDAP_MALLOC_CALLBACK *ldapmem_malloc;
|
||||
LDAP_CALLOC_CALLBACK *ldapmem_calloc;
|
||||
LDAP_REALLOC_CALLBACK *ldapmem_realloc;
|
||||
LDAP_FREE_CALLBACK *ldapmem_free;
|
||||
};
|
||||
#define LDAP_OPT_MEMALLOC_FN_PTRS 97 /* Netscape extension */
|
||||
|
||||
#define LDAP_OPT_RECONNECT 98 /* Netscape extension */
|
||||
|
||||
#define LDAP_OPT_EXTRA_THREAD_FN_PTRS 101 /* Netscape extension */
|
||||
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_TRYLOCK_CALLBACK)( void * );
|
||||
typedef void *(LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_ALLOC_CALLBACK)( void );
|
||||
typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_FREE_CALLBACK)( void * );
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_WAIT_CALLBACK)( void * );
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_POST_CALLBACK)( void * );
|
||||
|
||||
struct ldap_extra_thread_fns {
|
||||
LDAP_TF_MUTEX_TRYLOCK_CALLBACK *ltf_mutex_trylock;
|
||||
LDAP_TF_SEMA_ALLOC_CALLBACK *ltf_sema_alloc;
|
||||
LDAP_TF_SEMA_FREE_CALLBACK *ltf_sema_free;
|
||||
LDAP_TF_SEMA_WAIT_CALLBACK *ltf_sema_wait;
|
||||
LDAP_TF_SEMA_POST_CALLBACK *ltf_sema_post;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define LDAP_OPT_ASYNC_CONNECT 99 /* Netscape extension */
|
||||
#define LDAP_OPT_ASYNC_RECONNECT_FN_PTR 100 /* Netscape extension */
|
||||
|
||||
|
||||
/*
|
||||
* this function sets the connect status of the ld so that a client
|
||||
* can do dns and connect, and then tell the sdk to ignore the connect phase
|
||||
*/
|
||||
|
||||
LDAP_API(int) LDAP_CALL ldap_set_connected( LDAP *ld,
|
||||
const int currentstatus );
|
||||
|
||||
/*
|
||||
* callback definition for reconnect request from a referral
|
||||
*/
|
||||
|
||||
typedef int( LDAP_C LDAP_CALLBACK LDAP_ASYNC_RECONNECT)( LBER_SOCKET,
|
||||
struct sockaddr *,
|
||||
int );
|
||||
|
||||
struct ldap_async_connect_fns
|
||||
{
|
||||
LDAP_ASYNC_RECONNECT *lac_reconnect;
|
||||
};
|
||||
|
||||
|
||||
/************************ end of experimental section ************************/
|
||||
|
||||
|
||||
/********** the functions, etc. below are unsupported at this time ***********/
|
||||
#ifdef LDAP_DNS
|
||||
#define LDAP_OPT_DNS 12
|
||||
#endif
|
||||
|
||||
#define LDAP_OPT_HOST_NAME 48 /* MSFT extension */
|
||||
#define LDAP_OPT_RETURN_REFERRALS 51 /* MSFT extension */
|
||||
|
||||
|
||||
/*
|
||||
* generalized bind
|
||||
*/
|
||||
LDAP_API(int) LDAP_CALL ldap_bind( LDAP *ld, const char *who,
|
||||
const char *passwd, int authmethod );
|
||||
LDAP_API(int) LDAP_CALL ldap_bind_s( LDAP *ld, const char *who,
|
||||
const char *cred, int method );
|
||||
|
||||
/*
|
||||
* experimental DN format support
|
||||
*/
|
||||
LDAP_API(int) LDAP_CALL ldap_is_dns_dn( const char *dn );
|
||||
|
||||
|
||||
/*
|
||||
* user friendly naming/searching routines
|
||||
*/
|
||||
LDAP_API(int) LDAP_CALL ldap_ufn_search_c( LDAP *ld, char *ufn,
|
||||
char **attrs, int attrsonly, LDAPMessage **res,
|
||||
LDAP_CANCELPROC_CALLBACK *cancelproc, void *cancelparm );
|
||||
LDAP_API(int) LDAP_CALL ldap_ufn_search_ct( LDAP *ld, char *ufn,
|
||||
char **attrs, int attrsonly, LDAPMessage **res,
|
||||
LDAP_CANCELPROC_CALLBACK *cancelproc, void *cancelparm,
|
||||
char *tag1, char *tag2, char *tag3 );
|
||||
LDAP_API(int) LDAP_CALL ldap_ufn_search_s( LDAP *ld, char *ufn,
|
||||
char **attrs, int attrsonly, LDAPMessage **res );
|
||||
LDAP_API(LDAPFiltDesc *) LDAP_CALL ldap_ufn_setfilter( LDAP *ld, char *fname );
|
||||
LDAP_API(void) LDAP_CALL ldap_ufn_setprefix( LDAP *ld, char *prefix );
|
||||
LDAP_API(int) LDAP_C ldap_ufn_timeout( void *tvparam );
|
||||
|
||||
/*
|
||||
* utility routines
|
||||
*/
|
||||
LDAP_API(int) LDAP_CALL ldap_charray_add( char ***a, char *s );
|
||||
LDAP_API(int) LDAP_CALL ldap_charray_merge( char ***a, char **s );
|
||||
LDAP_API(void) LDAP_CALL ldap_charray_free( char **array );
|
||||
LDAP_API(int) LDAP_CALL ldap_charray_inlist( char **a, char *s );
|
||||
LDAP_API(char **) LDAP_CALL ldap_charray_dup( char **a );
|
||||
LDAP_API(char **) LDAP_CALL ldap_str2charray( char *str, char *brkstr );
|
||||
LDAP_API(int) LDAP_CALL ldap_charray_position( char **a, char *s );
|
||||
|
||||
/*
|
||||
* UTF-8 routines (should these move into libnls?)
|
||||
*/
|
||||
/* number of bytes in character */
|
||||
LDAP_API(int) LDAP_CALL ldap_utf8len( const char* );
|
||||
/* find next character */
|
||||
LDAP_API(char*) LDAP_CALL ldap_utf8next( char* );
|
||||
/* find previous character */
|
||||
LDAP_API(char*) LDAP_CALL ldap_utf8prev( char* );
|
||||
/* copy one character */
|
||||
LDAP_API(int) LDAP_CALL ldap_utf8copy( char* dst, const char* src );
|
||||
/* total number of characters */
|
||||
LDAP_API(size_t) LDAP_CALL ldap_utf8characters( const char* );
|
||||
/* get one UCS-4 character, and move *src to the next character */
|
||||
LDAP_API(unsigned long) LDAP_CALL ldap_utf8getcc( const char** src );
|
||||
/* UTF-8 aware strtok_r() */
|
||||
LDAP_API(char*) LDAP_CALL ldap_utf8strtok_r( char* src, const char* brk, char** next);
|
||||
|
||||
/* like isalnum(*s) in the C locale */
|
||||
LDAP_API(int) LDAP_CALL ldap_utf8isalnum( char* s );
|
||||
/* like isalpha(*s) in the C locale */
|
||||
LDAP_API(int) LDAP_CALL ldap_utf8isalpha( char* s );
|
||||
/* like isdigit(*s) in the C locale */
|
||||
LDAP_API(int) LDAP_CALL ldap_utf8isdigit( char* s );
|
||||
/* like isxdigit(*s) in the C locale */
|
||||
LDAP_API(int) LDAP_CALL ldap_utf8isxdigit(char* s );
|
||||
/* like isspace(*s) in the C locale */
|
||||
LDAP_API(int) LDAP_CALL ldap_utf8isspace( char* s );
|
||||
|
||||
#define LDAP_UTF8LEN(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8len (s) : 1)
|
||||
#define LDAP_UTF8NEXT(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8next(s) : (s)+1)
|
||||
#define LDAP_UTF8INC(s) ((0x80 & *(unsigned char*)(s)) ? s=ldap_utf8next(s) : ++s)
|
||||
|
||||
#define LDAP_UTF8PREV(s) ldap_utf8prev(s)
|
||||
#define LDAP_UTF8DEC(s) (s=ldap_utf8prev(s))
|
||||
|
||||
#define LDAP_UTF8COPY(d,s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8copy(d,s) : ((*(d) = *(s)), 1))
|
||||
#define LDAP_UTF8GETCC(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8getcc (&s) : *s++)
|
||||
#define LDAP_UTF8GETC(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8getcc ((const char**)&s) : *s++)
|
||||
|
||||
/*
|
||||
* functions that have been replaced by new improved ones
|
||||
*/
|
||||
/* use ldap_create_filter() instead of ldap_build_filter() */
|
||||
LDAP_API(void) LDAP_CALL ldap_build_filter( char *buf, unsigned long buflen,
|
||||
char *pattern, char *prefix, char *suffix, char *attr,
|
||||
char *value, char **valwords );
|
||||
/* use ldap_set_filter_additions() instead of ldap_setfilteraffixes() */
|
||||
LDAP_API(void) LDAP_CALL ldap_setfilteraffixes( LDAPFiltDesc *lfdp,
|
||||
char *prefix, char *suffix );
|
||||
|
||||
/* cache strategies */
|
||||
#define LDAP_CACHE_CHECK 0
|
||||
#define LDAP_CACHE_POPULATE 1
|
||||
#define LDAP_CACHE_LOCALDB 2
|
||||
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_BIND_CALLBACK)( LDAP *, int,
|
||||
unsigned long, const char *, struct berval *, int );
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_UNBIND_CALLBACK)( LDAP *, int,
|
||||
unsigned long );
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_SEARCH_CALLBACK)( LDAP *,
|
||||
int, unsigned long, const char *, int, const char LDAP_CALLBACK *,
|
||||
char **, int );
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_COMPARE_CALLBACK)( LDAP *, int,
|
||||
unsigned long, const char *, const char *, struct berval * );
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_ADD_CALLBACK)( LDAP *, int,
|
||||
unsigned long, const char *, LDAPMod ** );
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_DELETE_CALLBACK)( LDAP *, int,
|
||||
unsigned long, const char * );
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_MODIFY_CALLBACK)( LDAP *, int,
|
||||
unsigned long, const char *, LDAPMod ** );
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_MODRDN_CALLBACK)( LDAP *, int,
|
||||
unsigned long, const char *, const char *, int );
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_RESULT_CALLBACK)( LDAP *, int,
|
||||
int, struct timeval *, LDAPMessage ** );
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_FLUSH_CALLBACK)( LDAP *,
|
||||
const char *, const char * );
|
||||
|
||||
struct ldap_cache_fns {
|
||||
void *lcf_private;
|
||||
LDAP_CF_BIND_CALLBACK *lcf_bind;
|
||||
LDAP_CF_UNBIND_CALLBACK *lcf_unbind;
|
||||
LDAP_CF_SEARCH_CALLBACK *lcf_search;
|
||||
LDAP_CF_COMPARE_CALLBACK *lcf_compare;
|
||||
LDAP_CF_ADD_CALLBACK *lcf_add;
|
||||
LDAP_CF_DELETE_CALLBACK *lcf_delete;
|
||||
LDAP_CF_MODIFY_CALLBACK *lcf_modify;
|
||||
LDAP_CF_MODRDN_CALLBACK *lcf_modrdn;
|
||||
LDAP_CF_RESULT_CALLBACK *lcf_result;
|
||||
LDAP_CF_FLUSH_CALLBACK *lcf_flush;
|
||||
};
|
||||
|
||||
LDAP_API(int) LDAP_CALL ldap_cache_flush( LDAP *ld, const char *dn,
|
||||
const char *filter );
|
||||
|
||||
/*********************** end of unsupported functions ************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _LDAP_H */
|
||||
68
mozilla/directory/c-sdk/ldap/include/ldaplog.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef _LDAPLOG_H
|
||||
#define _LDAPLOG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LDAP_DEBUG_TRACE 0x00001
|
||||
#define LDAP_DEBUG_PACKETS 0x00002
|
||||
#define LDAP_DEBUG_ARGS 0x00004
|
||||
#define LDAP_DEBUG_CONNS 0x00008
|
||||
#define LDAP_DEBUG_BER 0x00010
|
||||
#define LDAP_DEBUG_FILTER 0x00020
|
||||
#define LDAP_DEBUG_CONFIG 0x00040
|
||||
#define LDAP_DEBUG_ACL 0x00080
|
||||
#define LDAP_DEBUG_STATS 0x00100
|
||||
#define LDAP_DEBUG_STATS2 0x00200
|
||||
#define LDAP_DEBUG_SHELL 0x00400
|
||||
#define LDAP_DEBUG_PARSE 0x00800
|
||||
#define LDAP_DEBUG_HOUSE 0x01000
|
||||
#define LDAP_DEBUG_REPL 0x02000
|
||||
#define LDAP_DEBUG_ANY 0x04000
|
||||
#define LDAP_DEBUG_CACHE 0x08000
|
||||
#define LDAP_DEBUG_PLUGIN 0x10000
|
||||
|
||||
/* debugging stuff */
|
||||
/* Disable by default */
|
||||
#define LDAPDebug( level, fmt, arg1, arg2, arg3 )
|
||||
|
||||
#ifdef LDAP_DEBUG
|
||||
# undef LDAPDebug
|
||||
|
||||
/* SLAPD_LOGGING should not be on for WINSOCK (16-bit Windows) */
|
||||
# if defined(SLAPD_LOGGING)
|
||||
# ifdef _WIN32
|
||||
extern int *module_ldap_debug;
|
||||
# define LDAPDebug( level, fmt, arg1, arg2, arg3 ) \
|
||||
{ \
|
||||
if ( *module_ldap_debug & level ) { \
|
||||
slapd_log_error_proc( NULL, fmt, arg1, arg2, arg3 ); \
|
||||
} \
|
||||
}
|
||||
# else /* _WIN32 */
|
||||
extern int ldap_debug;
|
||||
# define LDAPDebug( level, fmt, arg1, arg2, arg3 ) \
|
||||
{ \
|
||||
if ( ldap_debug & level ) { \
|
||||
slapd_log_error_proc( NULL, fmt, arg1, arg2, arg3 ); \
|
||||
} \
|
||||
}
|
||||
# endif /* Win32 */
|
||||
# else /* no SLAPD_LOGGING */
|
||||
extern void ber_err_print( char * );
|
||||
extern int ldap_debug;
|
||||
# define LDAPDebug( level, fmt, arg1, arg2, arg3 ) \
|
||||
if ( ldap_debug & level ) { \
|
||||
char msg[256]; \
|
||||
sprintf( msg, fmt, arg1, arg2, arg3 ); \
|
||||
ber_err_print( msg ); \
|
||||
}
|
||||
# endif /* SLAPD_LOGGING */
|
||||
#endif /* LDAP_DEBUG */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _LDAP_H */
|
||||
158
mozilla/directory/c-sdk/ldap/include/ldaprot.h
Normal file
@@ -0,0 +1,158 @@
|
||||
#ifndef _LDAPROT_H
|
||||
#define _LDAPROT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LDAP_VERSION1 1
|
||||
#define LDAP_VERSION2 2
|
||||
#define LDAP_VERSION3 3
|
||||
#define LDAP_VERSION LDAP_VERSION2
|
||||
|
||||
#define COMPAT20
|
||||
#define COMPAT30
|
||||
#if defined(COMPAT20) || defined(COMPAT30)
|
||||
#define COMPAT
|
||||
#endif
|
||||
|
||||
#define LDAP_URL_PREFIX "ldap://"
|
||||
#define LDAP_URL_PREFIX_LEN 7
|
||||
#define LDAPS_URL_PREFIX "ldaps://"
|
||||
#define LDAPS_URL_PREFIX_LEN 8
|
||||
#define LDAP_REF_STR "Referral:\n"
|
||||
#define LDAP_REF_STR_LEN 10
|
||||
|
||||
/*
|
||||
* specific LDAP instantiations of BER types we know about
|
||||
*/
|
||||
|
||||
/* general stuff */
|
||||
#define LDAP_TAG_MESSAGE 0x30L /* tag is 16 + constructed bit */
|
||||
#define OLD_LDAP_TAG_MESSAGE 0x10L /* forgot the constructed bit */
|
||||
#define LDAP_TAG_MSGID 0x02L /* INTEGER */
|
||||
#define LDAP_TAG_LDAPDN 0x04L /* OCTET STRING */
|
||||
#define LDAP_TAG_CONTROLS 0xa0L /* context specific + constructed + 0 */
|
||||
#define LDAP_TAG_REFERRAL 0xa3L /* context specific + constructed */
|
||||
#define LDAP_TAG_NEWSUPERIOR 0x80L /* context specific + primitive */
|
||||
#define LDAP_TAG_MRA_OID 0x81L /* context specific + primitive */
|
||||
#define LDAP_TAG_MRA_TYPE 0x82L /* context specific + primitive */
|
||||
#define LDAP_TAG_MRA_VALUE 0x83L /* context specific + primitive */
|
||||
#define LDAP_TAG_MRA_DNATTRS 0x84L /* context specific + primitive */
|
||||
#define LDAP_TAG_EXOP_REQ_OID 0x80L /* context specific + primitive */
|
||||
#define LDAP_TAG_EXOP_REQ_VALUE 0x81L /* context specific + primitive */
|
||||
#define LDAP_TAG_EXOP_RES_OID 0x8aL /* context specific + primitive */
|
||||
#define LDAP_TAG_EXOP_RES_VALUE 0x8bL /* context specific + primitive */
|
||||
#define LDAP_TAG_SK_MATCHRULE 0x80L /* context specific + primitive */
|
||||
#define LDAP_TAG_SK_REVERSE 0x81L /* context specific + primitive */
|
||||
#define LDAP_TAG_SR_ATTRTYPE 0x80L /* context specific + primitive */
|
||||
#define LDAP_TAG_SASL_RES_CREDS 0x87L /* context specific + primitive */
|
||||
#define LDAP_TAG_VLV_BY_INDEX 0xa0L /* context specific + constructed + 0 */
|
||||
#define LDAP_TAG_VLV_BY_VALUE 0x81L /* context specific + primitive + 1 */
|
||||
|
||||
/* possible operations a client can invoke */
|
||||
#define LDAP_REQ_BIND 0x60L /* application + constructed */
|
||||
#define LDAP_REQ_UNBIND 0x42L /* application + primitive */
|
||||
#define LDAP_REQ_SEARCH 0x63L /* application + constructed */
|
||||
#define LDAP_REQ_MODIFY 0x66L /* application + constructed */
|
||||
#define LDAP_REQ_ADD 0x68L /* application + constructed */
|
||||
#define LDAP_REQ_DELETE 0x4aL /* application + primitive */
|
||||
#define LDAP_REQ_MODRDN 0x6cL /* application + constructed */
|
||||
#define LDAP_REQ_MODDN 0x6cL /* application + constructed */
|
||||
#define LDAP_REQ_RENAME 0x6cL /* application + constructed */
|
||||
#define LDAP_REQ_COMPARE 0x6eL /* application + constructed */
|
||||
#define LDAP_REQ_ABANDON 0x50L /* application + primitive */
|
||||
#define LDAP_REQ_EXTENDED 0x77L /* application + constructed */
|
||||
|
||||
/* U-M LDAP release 3.0 compatibility stuff */
|
||||
#define LDAP_REQ_UNBIND_30 0x62L
|
||||
#define LDAP_REQ_DELETE_30 0x6aL
|
||||
#define LDAP_REQ_ABANDON_30 0x70L
|
||||
|
||||
/*
|
||||
* old broken stuff for backwards compatibility - forgot application tag
|
||||
* and constructed/primitive bit
|
||||
*/
|
||||
#define OLD_LDAP_REQ_BIND 0x00L
|
||||
#define OLD_LDAP_REQ_UNBIND 0x02L
|
||||
#define OLD_LDAP_REQ_SEARCH 0x03L
|
||||
#define OLD_LDAP_REQ_MODIFY 0x06L
|
||||
#define OLD_LDAP_REQ_ADD 0x08L
|
||||
#define OLD_LDAP_REQ_DELETE 0x0aL
|
||||
#define OLD_LDAP_REQ_MODRDN 0x0cL
|
||||
#define OLD_LDAP_REQ_MODDN 0x0cL
|
||||
#define OLD_LDAP_REQ_COMPARE 0x0eL
|
||||
#define OLD_LDAP_REQ_ABANDON 0x10L
|
||||
|
||||
/* old broken stuff for backwards compatibility */
|
||||
#define OLD_LDAP_RES_BIND 0x01L
|
||||
#define OLD_LDAP_RES_SEARCH_ENTRY 0x04L
|
||||
#define OLD_LDAP_RES_SEARCH_RESULT 0x05L
|
||||
#define OLD_LDAP_RES_MODIFY 0x07L
|
||||
#define OLD_LDAP_RES_ADD 0x09L
|
||||
#define OLD_LDAP_RES_DELETE 0x0bL
|
||||
#define OLD_LDAP_RES_MODRDN 0x0dL
|
||||
#define OLD_LDAP_RES_MODDN 0x0dL
|
||||
#define OLD_LDAP_RES_COMPARE 0x0fL
|
||||
|
||||
/* 3.0 compatibility auth methods */
|
||||
#define LDAP_AUTH_SIMPLE_30 0xa0L /* context specific + constructed */
|
||||
#define LDAP_AUTH_KRBV41_30 0xa1L /* context specific + constructed */
|
||||
#define LDAP_AUTH_KRBV42_30 0xa2L /* context specific + constructed */
|
||||
|
||||
/* old broken stuff */
|
||||
#define OLD_LDAP_AUTH_SIMPLE 0x00L
|
||||
#define OLD_LDAP_AUTH_KRBV4 0x01L
|
||||
#define OLD_LDAP_AUTH_KRBV42 0x02L
|
||||
|
||||
/* 3.0 compatibility filter types */
|
||||
#define LDAP_FILTER_PRESENT_30 0xa7L /* context specific + constructed */
|
||||
|
||||
/* filter types */
|
||||
#define LDAP_FILTER_AND 0xa0L /* context specific + constructed */
|
||||
#define LDAP_FILTER_OR 0xa1L /* context specific + constructed */
|
||||
#define LDAP_FILTER_NOT 0xa2L /* context specific + constructed */
|
||||
#define LDAP_FILTER_EQUALITY 0xa3L /* context specific + constructed */
|
||||
#define LDAP_FILTER_SUBSTRINGS 0xa4L /* context specific + constructed */
|
||||
#define LDAP_FILTER_GE 0xa5L /* context specific + constructed */
|
||||
#define LDAP_FILTER_LE 0xa6L /* context specific + constructed */
|
||||
#define LDAP_FILTER_PRESENT 0x87L /* context specific + primitive */
|
||||
#define LDAP_FILTER_APPROX 0xa8L /* context specific + constructed */
|
||||
#define LDAP_FILTER_EXTENDED 0xa9L /* context specific + constructed */
|
||||
|
||||
/* old broken stuff */
|
||||
#define OLD_LDAP_FILTER_AND 0x00L
|
||||
#define OLD_LDAP_FILTER_OR 0x01L
|
||||
#define OLD_LDAP_FILTER_NOT 0x02L
|
||||
#define OLD_LDAP_FILTER_EQUALITY 0x03L
|
||||
#define OLD_LDAP_FILTER_SUBSTRINGS 0x04L
|
||||
#define OLD_LDAP_FILTER_GE 0x05L
|
||||
#define OLD_LDAP_FILTER_LE 0x06L
|
||||
#define OLD_LDAP_FILTER_PRESENT 0x07L
|
||||
#define OLD_LDAP_FILTER_APPROX 0x08L
|
||||
|
||||
/* substring filter component types */
|
||||
#define LDAP_SUBSTRING_INITIAL 0x80L /* context specific */
|
||||
#define LDAP_SUBSTRING_ANY 0x81L /* context specific */
|
||||
#define LDAP_SUBSTRING_FINAL 0x82L /* context specific */
|
||||
|
||||
/* extended filter component types */
|
||||
#define LDAP_FILTER_EXTENDED_OID 0x81L /* context specific */
|
||||
#define LDAP_FILTER_EXTENDED_TYPE 0x82L /* context specific */
|
||||
#define LDAP_FILTER_EXTENDED_VALUE 0x83L /* context specific */
|
||||
#define LDAP_FILTER_EXTENDED_DNATTRS 0x84L /* context specific */
|
||||
|
||||
/* 3.0 compatibility substring filter component types */
|
||||
#define LDAP_SUBSTRING_INITIAL_30 0xa0L /* context specific */
|
||||
#define LDAP_SUBSTRING_ANY_30 0xa1L /* context specific */
|
||||
#define LDAP_SUBSTRING_FINAL_30 0xa2L /* context specific */
|
||||
|
||||
/* old broken stuff */
|
||||
#define OLD_LDAP_SUBSTRING_INITIAL 0x00L
|
||||
#define OLD_LDAP_SUBSTRING_ANY 0x01L
|
||||
#define OLD_LDAP_SUBSTRING_FINAL 0x02L
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _LDAPROT_H */
|
||||
57
mozilla/directory/c-sdk/ldap/include/ldif.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 1996 Regents of the University of Michigan.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that this notice is preserved and that due credit is given
|
||||
* to the University of Michigan at Ann Arbor. The name of the University
|
||||
* may not be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission. This software
|
||||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
|
||||
#ifndef _LDIF_H
|
||||
#define _LDIF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LDIF_MAX_LINE_WIDTH 76 /* maximum length of LDIF lines */
|
||||
|
||||
/*
|
||||
* Macro to calculate maximum number of bytes that the base64 equivalent
|
||||
* of an item that is "vlen" bytes long will take up. Base64 encoding
|
||||
* uses one byte for every six bits in the value plus up to two pad bytes.
|
||||
*/
|
||||
#define LDIF_BASE64_LEN(vlen) (((vlen) * 4 / 3 ) + 3)
|
||||
|
||||
/*
|
||||
* Macro to calculate maximum size that an LDIF-encoded type (length
|
||||
* tlen) and value (length vlen) will take up: room for type + ":: " +
|
||||
* first newline + base64 value + continued lines. Each continued line
|
||||
* needs room for a newline and a leading space character.
|
||||
*/
|
||||
#define LDIF_SIZE_NEEDED(tlen,vlen) \
|
||||
((tlen) + 4 + LDIF_BASE64_LEN(vlen) \
|
||||
+ ((LDIF_BASE64_LEN(vlen) + tlen + 3) / LDIF_MAX_LINE_WIDTH * 2 ))
|
||||
|
||||
|
||||
int ldif_parse_line( char *line, char **type, char **value, int *vlen);
|
||||
char * ldif_getline( char **next );
|
||||
void ldif_put_type_and_value( char **out, char *t, char *val, int vlen );
|
||||
void ldif_put_type_and_value_nowrap( char **out, char *t, char *val, int vlen );
|
||||
char *ldif_type_and_value( char *type, char *val, int vlen );
|
||||
char *ldif_type_and_value_nowrap( char *type, char *val, int vlen );
|
||||
int ldif_base64_decode( char *src, unsigned char *dst );
|
||||
int ldif_base64_encode( unsigned char *src, char *dst, int srclen,
|
||||
int lenused );
|
||||
int ldif_base64_encode_nowrap( unsigned char *src, char *dst, int srclen,
|
||||
int lenused );
|
||||
char *ldif_get_entry( FILE *fp, int *lineno );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _LDIF_H */
|
||||
362
mozilla/directory/c-sdk/ldap/include/portable.h
Normal file
@@ -0,0 +1,362 @@
|
||||
/*
|
||||
* Copyright (c) 1994 Regents of the University of Michigan.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that this notice is preserved and that due credit is given
|
||||
* to the University of Michigan at Ann Arbor. The name of the University
|
||||
* may not be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission. This software
|
||||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
|
||||
#ifndef _PORTABLE_H
|
||||
#define _PORTABLE_H
|
||||
|
||||
/*
|
||||
* portable.h for LDAP -- this is where we define common stuff to make
|
||||
* life easier on various Unix systems.
|
||||
*
|
||||
* Unless you are porting LDAP to a new platform, you should not need to
|
||||
* edit this file.
|
||||
*/
|
||||
|
||||
#ifndef SYSV
|
||||
#if defined( hpux ) || defined( sunos5 ) || defined ( sgi ) || defined( SVR4 )
|
||||
#define SYSV
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* under System V, use sysconf() instead of getdtablesize
|
||||
*/
|
||||
#if !defined( USE_SYSCONF ) && defined( SYSV )
|
||||
#define USE_SYSCONF
|
||||
#endif
|
||||
|
||||
/*
|
||||
* under System V, daemons should use setsid() instead of detaching from their
|
||||
* tty themselves
|
||||
*/
|
||||
#if !defined( USE_SETSID ) && defined( SYSV )
|
||||
#define USE_SETSID
|
||||
#endif
|
||||
|
||||
/*
|
||||
* System V has socket options in filio.h
|
||||
*/
|
||||
#if !defined( NEED_FILIO ) && defined( SYSV ) && !defined( hpux ) && !defined( AIX )
|
||||
#define NEED_FILIO
|
||||
#endif
|
||||
|
||||
/*
|
||||
* use lockf() under System V
|
||||
*/
|
||||
#if !defined( USE_LOCKF ) && ( defined( SYSV ) || defined( aix ))
|
||||
#define USE_LOCKF
|
||||
#endif
|
||||
|
||||
/*
|
||||
* on many systems, we should use waitpid() instead of waitN()
|
||||
*/
|
||||
#if !defined( USE_WAITPID ) && ( defined( SYSV ) || defined( sunos4 ) || defined( ultrix ) || defined( aix ))
|
||||
#define USE_WAITPID
|
||||
#endif
|
||||
|
||||
/*
|
||||
* define the wait status argument type
|
||||
*/
|
||||
#if ( defined( SunOS ) && SunOS < 40 ) || defined( nextstep )
|
||||
#define WAITSTATUSTYPE union wait
|
||||
#else
|
||||
#define WAITSTATUSTYPE int
|
||||
#endif
|
||||
|
||||
/*
|
||||
* define the flags for wait
|
||||
*/
|
||||
#ifdef sunos5
|
||||
#define WAIT_FLAGS ( WNOHANG | WUNTRACED | WCONTINUED )
|
||||
#else
|
||||
#define WAIT_FLAGS ( WNOHANG | WUNTRACED )
|
||||
#endif
|
||||
|
||||
/*
|
||||
* defined the options for openlog (syslog)
|
||||
*/
|
||||
#ifdef ultrix
|
||||
#define OPENLOG_OPTIONS LOG_PID
|
||||
#else
|
||||
#define OPENLOG_OPTIONS ( LOG_PID | LOG_NOWAIT )
|
||||
#endif
|
||||
|
||||
/*
|
||||
* some systems don't have the BSD re_comp and re_exec routines
|
||||
*/
|
||||
#ifndef NEED_BSDREGEX
|
||||
#if ( defined( SYSV ) || defined( VMS ) || defined( netbsd ) || defined( freebsd ) || defined( linux )) && !defined(sgi)
|
||||
#define NEED_BSDREGEX
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* many systems do not have the setpwfile() library routine... we just
|
||||
* enable use for those systems we know have it.
|
||||
*/
|
||||
#ifndef HAVE_SETPWFILE
|
||||
#if defined( sunos4 ) || defined( ultrix ) || defined( OSF1 )
|
||||
#define HAVE_SETPWFILE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Are sys_errlist and sys_nerr declared in stdio.h?
|
||||
*/
|
||||
#ifndef SYSERRLIST_IN_STDIO
|
||||
#if defined( freebsd )
|
||||
#define SYSERRLIST_IN_STDIO
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* for select()
|
||||
*/
|
||||
#if !defined(WINSOCK) && !defined(_WINDOWS) && !defined(macintosh) && !defined(XP_OS2)
|
||||
#if defined(hpux) || defined(LINUX2_0)
|
||||
#include <sys/time.h>
|
||||
#else
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
#if !defined(FD_SET)
|
||||
#define NFDBITS 32
|
||||
#define FD_SETSIZE 32
|
||||
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
|
||||
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
|
||||
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
|
||||
#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
|
||||
#endif /* !FD_SET */
|
||||
#endif /* !WINSOCK && !_WINDOWS && !macintosh */
|
||||
|
||||
|
||||
/*
|
||||
* for connect() -- must we block signals when calling connect()? This
|
||||
* is necessary on some buggy UNIXes.
|
||||
*/
|
||||
#if !defined(LDAP_CONNECT_MUST_NOT_BE_INTERRUPTED) && \
|
||||
( defined(AIX) || defined(IRIX) || defined(HPUX) || defined(SUNOS4) \
|
||||
|| defined(SOLARIS))
|
||||
#define LDAP_CONNECT_MUST_NOT_BE_INTERRUPTED
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* for signal() -- what do signal handling functions return?
|
||||
*/
|
||||
#ifndef SIG_FN
|
||||
#ifdef sunos5
|
||||
# define SIG_FN void /* signal-catching functions return void */
|
||||
#else /* sunos5 */
|
||||
# ifdef BSD
|
||||
# if (BSD >= 199006) || defined(NeXT) || defined(OSF1) || defined(sun) || defined(ultrix) || defined(apollo) || defined(POSIX_SIGNALS)
|
||||
# define SIG_FN void /* signal-catching functions return void */
|
||||
# else
|
||||
# define SIG_FN int /* signal-catching functions return int */
|
||||
# endif
|
||||
# else /* BSD */
|
||||
# define SIG_FN void /* signal-catching functions return void */
|
||||
# endif /* BSD */
|
||||
#endif /* sunos5 */
|
||||
#endif /* SIG_FN */
|
||||
|
||||
/*
|
||||
* toupper and tolower macros are different under bsd and sys v
|
||||
*/
|
||||
#if defined( SYSV ) && !defined( hpux )
|
||||
#define TOUPPER(c) (isascii(c) && islower(c) ? _toupper(c) : c)
|
||||
#define TOLOWER(c) (isascii(c) && isupper(c) ? _tolower(c) : c)
|
||||
#else
|
||||
#define TOUPPER(c) (isascii(c) && islower(c) ? toupper(c) : c)
|
||||
#define TOLOWER(c) (isascii(c) && isupper(c) ? tolower(c) : c)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* put a cover on the tty-related ioctl calls we need to use
|
||||
*/
|
||||
#if defined( NeXT ) || (defined(SunOS) && SunOS < 40)
|
||||
#define TERMIO_TYPE struct sgttyb
|
||||
#define TERMFLAG_TYPE int
|
||||
#define GETATTR( fd, tiop ) ioctl((fd), TIOCGETP, (caddr_t)(tiop))
|
||||
#define SETATTR( fd, tiop ) ioctl((fd), TIOCSETP, (caddr_t)(tiop))
|
||||
#define GETFLAGS( tio ) (tio).sg_flags
|
||||
#define SETFLAGS( tio, flags ) (tio).sg_flags = (flags)
|
||||
#else
|
||||
#define USE_TERMIOS
|
||||
#define TERMIO_TYPE struct termios
|
||||
#define TERMFLAG_TYPE tcflag_t
|
||||
#define GETATTR( fd, tiop ) tcgetattr((fd), (tiop))
|
||||
#define SETATTR( fd, tiop ) tcsetattr((fd), TCSANOW /* 0 */, (tiop))
|
||||
#define GETFLAGS( tio ) (tio).c_lflag
|
||||
#define SETFLAGS( tio, flags ) (tio).c_lflag = (flags)
|
||||
#endif
|
||||
|
||||
#if ( !defined( HPUX9 )) && ( !defined( sunos4 )) && ( !defined( SNI )) && \
|
||||
( !defined( HAVE_TIME_R ))
|
||||
#define HAVE_TIME_R
|
||||
#endif
|
||||
|
||||
#if defined( sunos5 ) || defined( aix )
|
||||
#define HAVE_GETPWNAM_R
|
||||
#define HAVE_GETGRNAM_R
|
||||
#endif
|
||||
|
||||
#if defined(SNI) || defined(LINUX1_2)
|
||||
int strcasecmp(const char *, const char *);
|
||||
#ifdef SNI
|
||||
int strncasecmp(const char *, const char *, int);
|
||||
#endif /* SNI */
|
||||
#ifdef LINUX1_2
|
||||
int strncasecmp(const char *, const char *, size_t);
|
||||
#endif /* LINUX1_2 */
|
||||
#endif /* SNI || LINUX1_2 */
|
||||
|
||||
#if defined(_WINDOWS) || defined(macintosh) || defined(XP_OS2)
|
||||
#define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname( n )
|
||||
#define CTIME( c, b, l ) ctime( c )
|
||||
#define STRTOK( s1, s2, l ) strtok( s1, s2 )
|
||||
#else /* UNIX */
|
||||
#if defined(sgi) || defined(HPUX9) || defined(LINUX1_2) || defined(SCOOS) || \
|
||||
defined(UNIXWARE) || defined(SUNOS4) || defined(SNI) || defined(BSDI) || \
|
||||
defined(NCR) || defined(OSF1) || defined(NEC) || \
|
||||
( defined(HPUX10) && !defined(_REENTRANT)) || defined(HPUX11) || \
|
||||
defined(UnixWare) || defined(LINUX2_0)
|
||||
#define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname( n )
|
||||
#elif defined(AIX)
|
||||
/* Maybe this is for another version of AIX?
|
||||
Commenting out for AIX 4.1 for Nova
|
||||
Replaced with following to lines, stolen from the #else below
|
||||
#define GETHOSTBYNAME_BUF_T struct hostent_data
|
||||
*/
|
||||
typedef char GETHOSTBYNAME_buf_t [BUFSIZ /* XXX might be too small */];
|
||||
#define GETHOSTBYNAME_BUF_T GETHOSTBYNAME_buf_t
|
||||
#define GETHOSTBYNAME( n, r, b, l, e ) \
|
||||
(memset (&b, 0, l), gethostbyname_r (n, r, &b) ? NULL : r)
|
||||
#elif defined(HPUX10)
|
||||
#define GETHOSTBYNAME_BUF_T struct hostent_data
|
||||
#define GETHOSTBYNAME( n, r, b, l, e ) nsldapi_compat_gethostbyname_r( n, r, (char *)&b, l, e )
|
||||
#else
|
||||
#include <stdio.h> /* BUFSIZ */
|
||||
typedef char GETHOSTBYNAME_buf_t [BUFSIZ /* XXX might be too small */];
|
||||
#define GETHOSTBYNAME_BUF_T GETHOSTBYNAME_buf_t
|
||||
#define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname_r( n, r, b, l, e )
|
||||
#endif
|
||||
#if defined(HPUX9) || defined(LINUX1_2) || defined(SUNOS4) || defined(SNI) || \
|
||||
defined(SCOOS) || defined(BSDI) || defined(NCR) || \
|
||||
defined(NEC) || ( defined(HPUX10) && !defined(_REENTRANT))
|
||||
#define CTIME( c, b, l ) ctime( c )
|
||||
#elif defined(HPUX10) && defined(_REENTRANT)
|
||||
#define CTIME( c, b, l ) nsldapi_compat_ctime_r( c, b, l )
|
||||
#elif defined( IRIX6_2 ) || defined( IRIX6_3 ) || defined(UNIXWARE) \
|
||||
|| defined(OSF1V4) || defined(AIX) || defined(UnixWare) || defined(hpux)
|
||||
#define CTIME( c, b, l ) ctime_r( c, b )
|
||||
#elif defined( OSF1V3 )
|
||||
#define CTIME( c, b, l ) (ctime_r( c, b, l ) ? NULL : b)
|
||||
#else
|
||||
#define CTIME( c, b, l ) ctime_r( c, b, l )
|
||||
#endif
|
||||
#if defined(hpux9) || defined(LINUX1_2) || defined(SUNOS4) || defined(SNI) || \
|
||||
defined(SCOOS) || defined(BSDI) || defined(NCR) || \
|
||||
defined(NEC) || defined(LINUX2_0)
|
||||
#define STRTOK( s1, s2, l ) strtok( s1, s2 )
|
||||
#else
|
||||
#define HAVE_STRTOK_R
|
||||
char *strtok_r(char *, const char *, char **);
|
||||
#define STRTOK( s1, s2, l ) (char *)strtok_r( s1, s2, l )
|
||||
#endif /* STRTOK */
|
||||
#endif /* UNIX */
|
||||
|
||||
#if defined( ultrix ) || defined( nextstep )
|
||||
extern char *strdup();
|
||||
#endif /* ultrix || nextstep */
|
||||
|
||||
#if defined( sunos4 ) || defined( OSF1 )
|
||||
#define BSD_TIME 1 /* for servers/slapd/log.h */
|
||||
#endif /* sunos4 || osf */
|
||||
|
||||
#ifdef SOLARIS
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h> /* for inet_addr() */
|
||||
#endif /* SOLARIS */
|
||||
|
||||
#ifdef SUNOS4
|
||||
#include <pcfs/pc_dir.h> /* for toupper() */
|
||||
int fprintf(FILE *, char *, ...);
|
||||
int fseek(FILE *, long, int);
|
||||
int fread(char *, int, int, FILE *);
|
||||
int fclose(FILE *);
|
||||
int fflush(FILE *);
|
||||
int rewind(FILE *);
|
||||
void *memmove(void *, const void *, size_t);
|
||||
int strcasecmp(char *, char *);
|
||||
int strncasecmp(char *, char *, int);
|
||||
time_t time(time_t *);
|
||||
void perror(char *);
|
||||
int fputc(char, FILE *);
|
||||
int fputs(char *, FILE *);
|
||||
int LDAP_CALL re_exec(char *);
|
||||
int socket(int, int, int);
|
||||
void bzero(char *, int);
|
||||
unsigned long inet_addr(char *);
|
||||
char * inet_ntoa(struct in_addr);
|
||||
int getdtablesize();
|
||||
int connect(int, struct sockaddr *, int);
|
||||
#endif /* SUNOS4 */
|
||||
|
||||
/* #if defined(SUNOS4) || defined(SNI) */
|
||||
#if defined(SUNOS4)
|
||||
int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
|
||||
#endif /* SUNOS4 || SNI */
|
||||
|
||||
/*
|
||||
* SAFEMEMCPY is an overlap-safe copy from s to d of n bytes
|
||||
*/
|
||||
#ifdef macintosh
|
||||
#define SAFEMEMCPY( d, s, n ) BlockMoveData( (Ptr)s, (Ptr)d, n )
|
||||
#else /* macintosh */
|
||||
#ifdef sunos4
|
||||
#define SAFEMEMCPY( d, s, n ) bcopy( s, d, n )
|
||||
#else /* sunos4 */
|
||||
#define SAFEMEMCPY( d, s, n ) memmove( d, s, n )
|
||||
#endif /* sunos4 */
|
||||
#endif /* macintosh */
|
||||
|
||||
#ifdef _WINDOWS
|
||||
|
||||
#define strcasecmp strcmpi
|
||||
#define strncasecmp _strnicmp
|
||||
#define bzero(a, b) memset( a, 0, b )
|
||||
#define getpid _getpid
|
||||
#define ioctl ioctlsocket
|
||||
#define sleep(a) Sleep( a*1000 )
|
||||
|
||||
#define EMSGSIZE WSAEMSGSIZE
|
||||
#define EWOULDBLOCK WSAEWOULDBLOCK
|
||||
#define EHOSTUNREACH WSAEHOSTUNREACH
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#define MAXPATHLEN _MAX_PATH
|
||||
#endif
|
||||
|
||||
#define DS_MAX_NT_SOCKET_CONNECTIONS 2000
|
||||
|
||||
#elif defined(XP_OS2)
|
||||
|
||||
#define strcasecmp strcmpi
|
||||
#define strncasecmp strnicmp
|
||||
#define bzero(a, b) memset( a, 0, b )
|
||||
#include "dirent.h"
|
||||
#include <string.h> /*for strcmpi()*/
|
||||
#include <time.h> /*for ctime()*/
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _PORTABLE_H */
|
||||
58
mozilla/directory/c-sdk/ldap/include/regex.h
Normal file
@@ -0,0 +1,58 @@
|
||||
#if defined( macintosh ) || defined( DOS ) || defined( _WINDOWS ) || defined( NEED_BSDREGEX ) || defined( XP_OS2 )
|
||||
/*
|
||||
* Copyright (c) 1993 Regents of the University of Michigan.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that this notice is preserved and that due credit is given
|
||||
* to the University of Michigan at Ann Arbor. The name of the University
|
||||
* may not be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission. This software
|
||||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
/*
|
||||
* regex.h -- includes for regular expression matching routines
|
||||
* 13 August 1993 Mark C Smith
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "ldap.h"
|
||||
|
||||
#if !defined( NEEDPROTOS ) && defined( __STDC__ )
|
||||
#define NEEDPROTOS
|
||||
#endif
|
||||
|
||||
#ifdef _SLDAPD_H_ /* server build: no need to use LDAP_CALL stuff */
|
||||
#ifdef LDAP_CALL
|
||||
#undef LDAP_CALL
|
||||
#define LDAP_CALL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef NEEDPROTOS
|
||||
int re_init( void );
|
||||
void re_lock( void );
|
||||
int re_unlock( void );
|
||||
char * LDAP_CALL re_comp( char *pat );
|
||||
int LDAP_CALL re_exec( char *lp );
|
||||
void LDAP_CALL re_modw( char *s );
|
||||
int LDAP_CALL re_subs( char *src, char *dst );
|
||||
#else /* NEEDPROTOS */
|
||||
int re_init();
|
||||
void re_lock();
|
||||
int re_unlock();
|
||||
char * LDAP_CALL re_comp();
|
||||
int LDAP_CALL re_exec();
|
||||
void LDAP_CALL re_modw();
|
||||
int LDAP_CALL re_subs();
|
||||
#endif /* NEEDPROTOS */
|
||||
|
||||
#define re_fail( m, p )
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* macintosh or DOS or or _WIN32 or NEED_BSDREGEX */
|
||||
118
mozilla/directory/c-sdk/ldap/include/srchpref.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (c) 1993, 1994 Regents of the University of Michigan.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that this notice is preserved and that due credit is given
|
||||
* to the University of Michigan at Ann Arbor. The name of the University
|
||||
* may not be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission. This software
|
||||
* is provided ``as is'' without express or implied warranty.
|
||||
*
|
||||
* searchpref.h: display template library defines
|
||||
* 16 May 1994 by Gordon Good
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _SRCHPREF_H
|
||||
#define _SRCHPREF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* calling conventions used by library */
|
||||
#ifndef LDAP_CALL
|
||||
#if defined( _WINDOWS ) || defined( _WIN32 )
|
||||
#define LDAP_C __cdecl
|
||||
#ifndef _WIN32
|
||||
#define __stdcall _far _pascal
|
||||
#define LDAP_CALLBACK _loadds
|
||||
#else
|
||||
#define LDAP_CALLBACK
|
||||
#endif /* _WIN32 */
|
||||
#define LDAP_PASCAL __stdcall
|
||||
#define LDAP_CALL LDAP_PASCAL
|
||||
#else /* _WINDOWS */
|
||||
#define LDAP_C
|
||||
#define LDAP_CALLBACK
|
||||
#define LDAP_PASCAL
|
||||
#define LDAP_CALL
|
||||
#endif /* _WINDOWS */
|
||||
#endif /* LDAP_CALL */
|
||||
|
||||
struct ldap_searchattr {
|
||||
char *sa_attrlabel;
|
||||
char *sa_attr;
|
||||
/* max 32 matchtypes for now */
|
||||
unsigned long sa_matchtypebitmap;
|
||||
char *sa_selectattr;
|
||||
char *sa_selecttext;
|
||||
struct ldap_searchattr *sa_next;
|
||||
};
|
||||
|
||||
struct ldap_searchmatch {
|
||||
char *sm_matchprompt;
|
||||
char *sm_filter;
|
||||
struct ldap_searchmatch *sm_next;
|
||||
};
|
||||
|
||||
struct ldap_searchobj {
|
||||
char *so_objtypeprompt;
|
||||
unsigned long so_options;
|
||||
char *so_prompt;
|
||||
short so_defaultscope;
|
||||
char *so_filterprefix;
|
||||
char *so_filtertag;
|
||||
char *so_defaultselectattr;
|
||||
char *so_defaultselecttext;
|
||||
struct ldap_searchattr *so_salist;
|
||||
struct ldap_searchmatch *so_smlist;
|
||||
struct ldap_searchobj *so_next;
|
||||
};
|
||||
|
||||
#define NULLSEARCHOBJ ((struct ldap_searchobj *)0)
|
||||
|
||||
/*
|
||||
* global search object options
|
||||
*/
|
||||
#define LDAP_SEARCHOBJ_OPT_INTERNAL 0x00000001
|
||||
|
||||
#define LDAP_IS_SEARCHOBJ_OPTION_SET( so, option ) \
|
||||
(((so)->so_options & option ) != 0 )
|
||||
|
||||
#define LDAP_SEARCHPREF_VERSION_ZERO 0
|
||||
#define LDAP_SEARCHPREF_VERSION 1
|
||||
|
||||
#define LDAP_SEARCHPREF_ERR_VERSION 1
|
||||
#define LDAP_SEARCHPREF_ERR_MEM 2
|
||||
#define LDAP_SEARCHPREF_ERR_SYNTAX 3
|
||||
#define LDAP_SEARCHPREF_ERR_FILE 4
|
||||
|
||||
|
||||
LDAP_API(int)
|
||||
LDAP_CALL
|
||||
ldap_init_searchprefs( char *file, struct ldap_searchobj **solistp );
|
||||
|
||||
LDAP_API(int)
|
||||
LDAP_CALL
|
||||
ldap_init_searchprefs_buf( char *buf, long buflen,
|
||||
struct ldap_searchobj **solistp );
|
||||
|
||||
LDAP_API(void)
|
||||
LDAP_CALL
|
||||
ldap_free_searchprefs( struct ldap_searchobj *solist );
|
||||
|
||||
LDAP_API(struct ldap_searchobj *)
|
||||
LDAP_CALL
|
||||
ldap_first_searchobj( struct ldap_searchobj *solist );
|
||||
|
||||
LDAP_API(struct ldap_searchobj *)
|
||||
LDAP_CALL
|
||||
ldap_next_searchobj( struct ldap_searchobj *sollist,
|
||||
struct ldap_searchobj *so );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _SRCHPREF_H */
|
||||
30
mozilla/directory/c-sdk/ldap/libraries/Makefile.client
Normal file
@@ -0,0 +1,30 @@
|
||||
DEPTH = ../../../..
|
||||
UNIXDIRLIST = liblber libldap
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
all export:: FORCE
|
||||
@for i in $(UNIXDIRLIST); do \
|
||||
echo " cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) export"; \
|
||||
( cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) export ); \
|
||||
done
|
||||
|
||||
libs install:: FORCE
|
||||
@for i in $(UNIXDIRLIST); do \
|
||||
echo " cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) install"; \
|
||||
( cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) install ); \
|
||||
done
|
||||
|
||||
clean clobber:: FORCE
|
||||
@for i in $(UNIXDIRLIST); do \
|
||||
echo " cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) clean"; \
|
||||
( cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) clean ); \
|
||||
done
|
||||
|
||||
realclean clobber_all:: FORCE
|
||||
@for i in $(UNIXDIRLIST); do \
|
||||
echo " cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) realclean"; \
|
||||
( cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) realclean ); \
|
||||
done
|
||||
|
||||
FORCE:
|
||||
@@ -0,0 +1,79 @@
|
||||
DEPTH = ../../../../..
|
||||
|
||||
LDAPSRC = ../..
|
||||
|
||||
RM = rm -f
|
||||
SED = sed
|
||||
|
||||
SRCS = decode.c \
|
||||
encode.c \
|
||||
io.c \
|
||||
bprint.c
|
||||
|
||||
REALOBJS = $(SRCS:.c=.o)
|
||||
|
||||
#OBJS = $(REALOBJS) versiont.o
|
||||
OBJS = $(REALOBJS)
|
||||
|
||||
HDIR = $(LDAPSRC)/include
|
||||
|
||||
LIBRARY_NAME = lber
|
||||
|
||||
#
|
||||
# DEFS are included in CFLAGS
|
||||
#
|
||||
DEFS = $(PLATFORMCFLAGS) $(LDAP_DEBUG) $(KERBEROS) $(AFSKERBEROS) \
|
||||
$(UOFM) $(UOFA) $(NO_USERINTERFACE) $(CLDAP) $(NO_CACHE) \
|
||||
$(LDAP_REFERRALS) $(LDAP_DNS) $(STR_TRANSLATION) \
|
||||
$(LIBLDAP_CHARSETS) $(LIBLDAP_DEF_CHARSET) \
|
||||
$(SLAPD_BACKENDS) $(LDBMBACKEND) $(LDBMINCLUDE) $(PHONETIC)
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
LOCAL_INCLUDES = -I$(PUBLIC)/nspr
|
||||
INCLUDES += -I$(HDIR)
|
||||
DEFINES += $(DEFS)
|
||||
|
||||
PLATFORMCFLAGS = -DUSE_WAITPID -DNEEDPROTOS
|
||||
PLATFORMLIBS =
|
||||
THREADS =
|
||||
THREADSLIB =
|
||||
|
||||
#
|
||||
# To build slapd (the stand-alone ldap daemon), uncomment the MAKESLAPD
|
||||
# line and select the SLAPD_BACKENDS you want to use. If you enable the
|
||||
# LDBM backend, also select one of the LDBM backends.
|
||||
#
|
||||
MAKESLAPD = yes
|
||||
SLAPD_BACKENDS = -DLDAP_LDBM -DLDAP_SHELL -DLDAP_PASSWD
|
||||
LDBMBACKEND = -DLDBM_USE_NDBM
|
||||
|
||||
#
|
||||
# uncomment this line to enable debugging code (a good idea)
|
||||
#
|
||||
ifndef BUILD_OPT
|
||||
LDAP_DEBUG = -DLDAP_DEBUG
|
||||
endif
|
||||
|
||||
#
|
||||
# uncomment this line to enable support for LDAP referrals in libldap
|
||||
#
|
||||
LDAP_REFERRALS = -DLDAP_REFERRALS
|
||||
|
||||
###########################################################################
|
||||
|
||||
versiont.c: Makefile.client Version.c
|
||||
@$(RM) $@
|
||||
@(u="$${USER-root}" v="$(shell cat ../../build/version)" d="$(shell pwd)" \
|
||||
h="$(shell hostname)" t="$(shell date)"; $(SED) -e "s|%WHEN%|$${t}|" \
|
||||
-e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \
|
||||
-e "s|%VERSION%|$${v}|" \
|
||||
< Version.c > $@)
|
||||
|
||||
$(LIBRARY): $(OBJS)
|
||||
|
||||
install::
|
||||
$(INSTALL) -m 444 $(LIBRARY) $(DIST)/ldap/lib
|
||||
ifdef MKSHLIB
|
||||
$(INSTALL) -m 555 $(SHARED_LIBRARY) $(DIST)/ldap/bin
|
||||
endif
|
||||
82
mozilla/directory/c-sdk/ldap/libraries/liblber/bprint.c
Normal file
@@ -0,0 +1,82 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* bprint.c - a printing utility for debuging output */
|
||||
#include <string.h>
|
||||
#include "lber-int.h"
|
||||
|
||||
#ifdef LDAP_DEBUG
|
||||
/*
|
||||
* Print arbitrary stuff, for debugging.
|
||||
*/
|
||||
|
||||
#define BPLEN 48
|
||||
|
||||
void
|
||||
lber_bprint( char *data, int len )
|
||||
{
|
||||
static char hexdig[] = "0123456789abcdef";
|
||||
char out[ BPLEN ];
|
||||
int i = 0;
|
||||
|
||||
memset( out, 0, BPLEN );
|
||||
for ( ;; ) {
|
||||
if ( len < 1 ) {
|
||||
char msg[BPLEN + 80];
|
||||
sprintf( msg, "\t%s\n", ( i == 0 ) ? "(end)" : out );
|
||||
ber_err_print( msg );
|
||||
break;
|
||||
}
|
||||
|
||||
#ifndef HEX
|
||||
if ( isgraph( (unsigned char)*data )) {
|
||||
out[ i ] = ' ';
|
||||
out[ i+1 ] = *data;
|
||||
} else {
|
||||
#endif
|
||||
out[ i ] = hexdig[ ( *data & 0xf0 ) >> 4 ];
|
||||
out[ i+1 ] = hexdig[ *data & 0x0f ];
|
||||
#ifndef HEX
|
||||
}
|
||||
#endif
|
||||
i += 2;
|
||||
len--;
|
||||
data++;
|
||||
|
||||
if ( i > BPLEN - 2 ) {
|
||||
char msg[BPLEN + 80];
|
||||
sprintf( msg, "\t%s\n", out );
|
||||
ber_err_print( msg );
|
||||
memset( out, 0, BPLEN );
|
||||
i = 0;
|
||||
continue;
|
||||
}
|
||||
out[ i++ ] = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void ber_err_print( char *data )
|
||||
{
|
||||
#ifdef USE_DEBUG_WIN
|
||||
OutputDebugString( data );
|
||||
#else
|
||||
fputs( data, stderr );
|
||||
fflush( stderr );
|
||||
#endif
|
||||
}
|
||||
621
mozilla/directory/c-sdk/ldap/libraries/liblber/decode.c
Normal file
@@ -0,0 +1,621 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990 Regents of the University of Michigan.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that this notice is preserved and that due credit is given
|
||||
* to the University of Michigan at Ann Arbor. The name of the University
|
||||
* may not be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission. This software
|
||||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
|
||||
/* decode.c - ber input decoding routines */
|
||||
|
||||
#include "lber-int.h"
|
||||
|
||||
/* return the tag - LBER_DEFAULT returned means trouble */
|
||||
unsigned long
|
||||
LDAP_CALL
|
||||
ber_get_tag( BerElement *ber )
|
||||
{
|
||||
unsigned char xbyte;
|
||||
unsigned long tag;
|
||||
char *tagp;
|
||||
int i;
|
||||
|
||||
if ( ber_read( ber, (char *) &xbyte, 1 ) != 1 )
|
||||
return( LBER_DEFAULT );
|
||||
|
||||
if ( (xbyte & LBER_BIG_TAG_MASK) != LBER_BIG_TAG_MASK )
|
||||
return( (unsigned long) xbyte );
|
||||
|
||||
tagp = (char *) &tag;
|
||||
tagp[0] = xbyte;
|
||||
for ( i = 1; i < sizeof(long); i++ ) {
|
||||
if ( ber_read( ber, (char *) &xbyte, 1 ) != 1 )
|
||||
return( LBER_DEFAULT );
|
||||
|
||||
tagp[i] = xbyte;
|
||||
|
||||
if ( ! (xbyte & LBER_MORE_TAG_MASK) )
|
||||
break;
|
||||
}
|
||||
|
||||
/* tag too big! */
|
||||
if ( i == sizeof(long) )
|
||||
return( LBER_DEFAULT );
|
||||
|
||||
/* want leading, not trailing 0's */
|
||||
return( tag >> (sizeof(long) - i - 1) );
|
||||
}
|
||||
|
||||
unsigned long
|
||||
LDAP_CALL
|
||||
ber_skip_tag( BerElement *ber, unsigned long *len )
|
||||
{
|
||||
unsigned long tag;
|
||||
unsigned char lc;
|
||||
int noctets, diff;
|
||||
unsigned long netlen;
|
||||
|
||||
/*
|
||||
* Any ber element looks like this: tag length contents.
|
||||
* Assuming everything's ok, we return the tag byte (we
|
||||
* can assume a single byte), and return the length in len.
|
||||
*
|
||||
* Assumptions:
|
||||
* 1) definite lengths
|
||||
* 2) primitive encodings used whenever possible
|
||||
*/
|
||||
|
||||
/*
|
||||
* First, we read the tag.
|
||||
*/
|
||||
|
||||
if ( (tag = ber_get_tag( ber )) == LBER_DEFAULT )
|
||||
return( LBER_DEFAULT );
|
||||
|
||||
/*
|
||||
* Next, read the length. The first byte contains the length of
|
||||
* the length. If bit 8 is set, the length is the long form,
|
||||
* otherwise it's the short form. We don't allow a length that's
|
||||
* greater than what we can hold in an unsigned long.
|
||||
*/
|
||||
|
||||
*len = netlen = 0;
|
||||
if ( ber_read( ber, (char *) &lc, 1 ) != 1 )
|
||||
return( LBER_DEFAULT );
|
||||
if ( lc & 0x80 ) {
|
||||
noctets = (lc & 0x7f);
|
||||
if ( noctets > sizeof(unsigned long) )
|
||||
return( LBER_DEFAULT );
|
||||
diff = sizeof(unsigned long) - noctets;
|
||||
if ( ber_read( ber, (char *) &netlen + diff, noctets )
|
||||
!= noctets )
|
||||
return( LBER_DEFAULT );
|
||||
*len = LBER_NTOHL( netlen );
|
||||
} else {
|
||||
*len = lc;
|
||||
}
|
||||
|
||||
return( tag );
|
||||
}
|
||||
|
||||
unsigned long
|
||||
LDAP_CALL
|
||||
ber_peek_tag( BerElement *ber, unsigned long *len )
|
||||
{
|
||||
char *save;
|
||||
unsigned long tag;
|
||||
|
||||
save = ber->ber_ptr;
|
||||
tag = ber_skip_tag( ber, len );
|
||||
ber->ber_ptr = save;
|
||||
|
||||
return( tag );
|
||||
}
|
||||
|
||||
static int
|
||||
ber_getnint( BerElement *ber, long *num, int len )
|
||||
{
|
||||
int i;
|
||||
long value;
|
||||
unsigned char buffer[sizeof(long)];
|
||||
/*
|
||||
* The tag and length have already been stripped off. We should
|
||||
* be sitting right before len bytes of 2's complement integer,
|
||||
* ready to be read straight into an int. We may have to sign
|
||||
* extend after we read it in.
|
||||
*/
|
||||
|
||||
if ( len > sizeof(long) )
|
||||
return( -1 );
|
||||
|
||||
/* read into the low-order bytes of netnum */
|
||||
if ( ber_read( ber, (char *) buffer, len ) != len )
|
||||
return( -1 );
|
||||
|
||||
/* This sets the required sign extension */
|
||||
if ( len != 0) {
|
||||
value = 0x80 & buffer[0] ? (-1L) : 0;
|
||||
} else {
|
||||
value = 0;
|
||||
}
|
||||
|
||||
for ( i = 0; i < len; i++ )
|
||||
value = (value << 8) | buffer[i];
|
||||
|
||||
*num = value;
|
||||
|
||||
return( len );
|
||||
}
|
||||
|
||||
unsigned long
|
||||
LDAP_CALL
|
||||
ber_get_int( BerElement *ber, long *num )
|
||||
{
|
||||
unsigned long tag, len;
|
||||
|
||||
if ( (tag = ber_skip_tag( ber, &len )) == LBER_DEFAULT )
|
||||
return( LBER_DEFAULT );
|
||||
|
||||
if ( ber_getnint( ber, num, (int)len ) != len )
|
||||
return( LBER_DEFAULT );
|
||||
else
|
||||
return( tag );
|
||||
}
|
||||
|
||||
unsigned long
|
||||
LDAP_CALL
|
||||
ber_get_stringb( BerElement *ber, char *buf, unsigned long *len )
|
||||
{
|
||||
unsigned long datalen, tag;
|
||||
#ifdef STR_TRANSLATION
|
||||
char *transbuf;
|
||||
#endif /* STR_TRANSLATION */
|
||||
|
||||
if ( (tag = ber_skip_tag( ber, &datalen )) == LBER_DEFAULT )
|
||||
return( LBER_DEFAULT );
|
||||
if ( datalen > (*len - 1) )
|
||||
return( LBER_DEFAULT );
|
||||
|
||||
if ( ber_read( ber, buf, datalen ) != datalen )
|
||||
return( LBER_DEFAULT );
|
||||
|
||||
buf[datalen] = '\0';
|
||||
|
||||
#ifdef STR_TRANSLATION
|
||||
if ( datalen > 0 && ( ber->ber_options & LBER_OPT_TRANSLATE_STRINGS )
|
||||
!= 0 && ber->ber_decode_translate_proc != NULL ) {
|
||||
transbuf = buf;
|
||||
++datalen;
|
||||
if ( (*(ber->ber_decode_translate_proc))( &transbuf, &datalen,
|
||||
0 ) != 0 ) {
|
||||
return( LBER_DEFAULT );
|
||||
}
|
||||
if ( datalen > *len ) {
|
||||
NSLBERI_FREE( transbuf );
|
||||
return( LBER_DEFAULT );
|
||||
}
|
||||
SAFEMEMCPY( buf, transbuf, datalen );
|
||||
NSLBERI_FREE( transbuf );
|
||||
--datalen;
|
||||
}
|
||||
#endif /* STR_TRANSLATION */
|
||||
|
||||
*len = datalen;
|
||||
return( tag );
|
||||
}
|
||||
|
||||
unsigned long
|
||||
LDAP_CALL
|
||||
ber_get_stringa( BerElement *ber, char **buf )
|
||||
{
|
||||
unsigned long datalen, tag;
|
||||
|
||||
if ( (tag = ber_skip_tag( ber, &datalen )) == LBER_DEFAULT )
|
||||
return( LBER_DEFAULT );
|
||||
|
||||
if ( (*buf = (char *)NSLBERI_MALLOC( (size_t)datalen + 1 )) == NULL )
|
||||
return( LBER_DEFAULT );
|
||||
|
||||
if ( ber_read( ber, *buf, datalen ) != datalen )
|
||||
return( LBER_DEFAULT );
|
||||
(*buf)[datalen] = '\0';
|
||||
|
||||
#ifdef STR_TRANSLATION
|
||||
if ( datalen > 0 && ( ber->ber_options & LBER_OPT_TRANSLATE_STRINGS )
|
||||
!= 0 && ber->ber_decode_translate_proc != NULL ) {
|
||||
++datalen;
|
||||
if ( (*(ber->ber_decode_translate_proc))( buf, &datalen, 1 )
|
||||
!= 0 ) {
|
||||
NSLBERI_FREE( *buf );
|
||||
return( LBER_DEFAULT );
|
||||
}
|
||||
}
|
||||
#endif /* STR_TRANSLATION */
|
||||
|
||||
return( tag );
|
||||
}
|
||||
|
||||
unsigned long
|
||||
LDAP_CALL
|
||||
ber_get_stringal( BerElement *ber, struct berval **bv )
|
||||
{
|
||||
unsigned long len, tag;
|
||||
|
||||
if ( (*bv = (struct berval *)NSLBERI_MALLOC( sizeof(struct berval) ))
|
||||
== NULL ) {
|
||||
return( LBER_DEFAULT );
|
||||
}
|
||||
|
||||
if ( (tag = ber_skip_tag( ber, &len )) == LBER_DEFAULT ) {
|
||||
return( LBER_DEFAULT );
|
||||
}
|
||||
|
||||
if ( ((*bv)->bv_val = (char *)NSLBERI_MALLOC( (size_t)len + 1 ))
|
||||
== NULL ) {
|
||||
return( LBER_DEFAULT );
|
||||
}
|
||||
|
||||
if ( ber_read( ber, (*bv)->bv_val, len ) != len )
|
||||
return( LBER_DEFAULT );
|
||||
((*bv)->bv_val)[len] = '\0';
|
||||
(*bv)->bv_len = len;
|
||||
|
||||
#ifdef STR_TRANSLATION
|
||||
if ( len > 0 && ( ber->ber_options & LBER_OPT_TRANSLATE_STRINGS ) != 0
|
||||
&& ber->ber_decode_translate_proc != NULL ) {
|
||||
++len;
|
||||
if ( (*(ber->ber_decode_translate_proc))( &((*bv)->bv_val),
|
||||
&len, 1 ) != 0 ) {
|
||||
NSLBERI_FREE( (*bv)->bv_val );
|
||||
return( LBER_DEFAULT );
|
||||
}
|
||||
(*bv)->bv_len = len - 1;
|
||||
}
|
||||
#endif /* STR_TRANSLATION */
|
||||
|
||||
return( tag );
|
||||
}
|
||||
|
||||
unsigned long
|
||||
LDAP_CALL
|
||||
ber_get_bitstringa( BerElement *ber, char **buf, unsigned long *blen )
|
||||
{
|
||||
unsigned long datalen, tag;
|
||||
unsigned char unusedbits;
|
||||
|
||||
if ( (tag = ber_skip_tag( ber, &datalen )) == LBER_DEFAULT )
|
||||
return( LBER_DEFAULT );
|
||||
--datalen;
|
||||
|
||||
if ( (*buf = (char *)NSLBERI_MALLOC( (size_t)datalen )) == NULL )
|
||||
return( LBER_DEFAULT );
|
||||
|
||||
if ( ber_read( ber, (char *)&unusedbits, 1 ) != 1 )
|
||||
return( LBER_DEFAULT );
|
||||
|
||||
if ( ber_read( ber, *buf, datalen ) != datalen )
|
||||
return( LBER_DEFAULT );
|
||||
|
||||
*blen = datalen * 8 - unusedbits;
|
||||
return( tag );
|
||||
}
|
||||
|
||||
unsigned long
|
||||
LDAP_CALL
|
||||
ber_get_null( BerElement *ber )
|
||||
{
|
||||
unsigned long len, tag;
|
||||
|
||||
if ( (tag = ber_skip_tag( ber, &len )) == LBER_DEFAULT )
|
||||
return( LBER_DEFAULT );
|
||||
|
||||
if ( len != 0 )
|
||||
return( LBER_DEFAULT );
|
||||
|
||||
return( tag );
|
||||
}
|
||||
|
||||
unsigned long
|
||||
LDAP_CALL
|
||||
ber_get_boolean( BerElement *ber, int *boolval )
|
||||
{
|
||||
long longbool;
|
||||
int rc;
|
||||
|
||||
rc = ber_get_int( ber, &longbool );
|
||||
*boolval = longbool;
|
||||
|
||||
return( rc );
|
||||
}
|
||||
|
||||
unsigned long
|
||||
LDAP_CALL
|
||||
ber_first_element( BerElement *ber, unsigned long *len, char **last )
|
||||
{
|
||||
/* skip the sequence header, use the len to mark where to stop */
|
||||
if ( ber_skip_tag( ber, len ) == LBER_DEFAULT ) {
|
||||
return( LBER_ERROR );
|
||||
}
|
||||
|
||||
*last = ber->ber_ptr + *len;
|
||||
|
||||
if ( *last == ber->ber_ptr ) {
|
||||
return( LBER_END_OF_SEQORSET );
|
||||
}
|
||||
|
||||
return( ber_peek_tag( ber, len ) );
|
||||
}
|
||||
|
||||
unsigned long
|
||||
LDAP_CALL
|
||||
ber_next_element( BerElement *ber, unsigned long *len, char *last )
|
||||
{
|
||||
if ( ber->ber_ptr == last ) {
|
||||
return( LBER_END_OF_SEQORSET );
|
||||
}
|
||||
|
||||
return( ber_peek_tag( ber, len ) );
|
||||
}
|
||||
|
||||
/* VARARGS */
|
||||
unsigned long
|
||||
LDAP_C
|
||||
ber_scanf( BerElement *ber, char *fmt, ... )
|
||||
{
|
||||
va_list ap;
|
||||
char *last;
|
||||
char *s, **ss, ***sss;
|
||||
struct berval ***bv, **bvp, *bval;
|
||||
int *i, j;
|
||||
long *l, rc, tag;
|
||||
unsigned long *t;
|
||||
unsigned long len;
|
||||
size_t array_size;
|
||||
|
||||
va_start( ap, fmt );
|
||||
|
||||
#ifdef LDAP_DEBUG
|
||||
if ( lber_debug & 64 ) {
|
||||
char msg[80];
|
||||
sprintf( msg, "ber_scanf fmt (%s) ber:\n", fmt );
|
||||
ber_err_print( msg );
|
||||
ber_dump( ber, 1 );
|
||||
}
|
||||
#endif
|
||||
|
||||
for ( rc = 0; *fmt && rc != LBER_DEFAULT; fmt++ ) {
|
||||
switch ( *fmt ) {
|
||||
case 'a': /* octet string - allocate storage as needed */
|
||||
ss = va_arg( ap, char ** );
|
||||
rc = ber_get_stringa( ber, ss );
|
||||
break;
|
||||
|
||||
case 'b': /* boolean */
|
||||
i = va_arg( ap, int * );
|
||||
rc = ber_get_boolean( ber, i );
|
||||
break;
|
||||
|
||||
case 'e': /* enumerated */
|
||||
case 'i': /* int */
|
||||
l = va_arg( ap, long * );
|
||||
rc = ber_get_int( ber, l );
|
||||
break;
|
||||
|
||||
case 'l': /* length of next item */
|
||||
l = va_arg( ap, long * );
|
||||
rc = ber_peek_tag( ber, (unsigned long *)l );
|
||||
break;
|
||||
|
||||
case 'n': /* null */
|
||||
rc = ber_get_null( ber );
|
||||
break;
|
||||
|
||||
case 's': /* octet string - in a buffer */
|
||||
s = va_arg( ap, char * );
|
||||
l = va_arg( ap, long * );
|
||||
rc = ber_get_stringb( ber, s, (unsigned long *)l );
|
||||
break;
|
||||
|
||||
case 'o': /* octet string in a supplied berval */
|
||||
bval = va_arg( ap, struct berval * );
|
||||
ber_peek_tag( ber, &bval->bv_len );
|
||||
rc = ber_get_stringa( ber, &bval->bv_val );
|
||||
break;
|
||||
|
||||
case 'O': /* octet string - allocate & include length */
|
||||
bvp = va_arg( ap, struct berval ** );
|
||||
rc = ber_get_stringal( ber, bvp );
|
||||
break;
|
||||
|
||||
case 'B': /* bit string - allocate storage as needed */
|
||||
ss = va_arg( ap, char ** );
|
||||
l = va_arg( ap, long * ); /* for length, in bits */
|
||||
rc = ber_get_bitstringa( ber, ss, (unsigned long *)l );
|
||||
break;
|
||||
|
||||
case 't': /* tag of next item */
|
||||
t = va_arg( ap, unsigned long * );
|
||||
*t = rc = ber_peek_tag( ber, &len );
|
||||
break;
|
||||
|
||||
case 'T': /* skip tag of next item */
|
||||
t = va_arg( ap, unsigned long * );
|
||||
*t = rc = ber_skip_tag( ber, &len );
|
||||
break;
|
||||
|
||||
case 'v': /* sequence of strings */
|
||||
sss = va_arg( ap, char *** );
|
||||
*sss = NULL;
|
||||
j = 0;
|
||||
array_size = 0;
|
||||
for ( tag = ber_first_element( ber, &len, &last );
|
||||
tag != LBER_DEFAULT && tag != LBER_END_OF_SEQORSET
|
||||
&& rc != LBER_DEFAULT;
|
||||
tag = ber_next_element( ber, &len, last ) ) {
|
||||
if ( *sss == NULL ) {
|
||||
/* Make room for at least 15 strings */
|
||||
*sss = (char **)NSLBERI_MALLOC(16 * sizeof(char *) );
|
||||
array_size = 16;
|
||||
} else {
|
||||
if ( (j+2) > array_size) {
|
||||
/* We'v overflowed our buffer */
|
||||
*sss = (char **)NSLBERI_REALLOC( *sss, (array_size * 2) * sizeof(char *) );
|
||||
array_size = array_size * 2;
|
||||
}
|
||||
}
|
||||
rc = ber_get_stringa( ber, &((*sss)[j]) );
|
||||
j++;
|
||||
}
|
||||
if ( rc != LBER_DEFAULT &&
|
||||
tag != LBER_END_OF_SEQORSET ) {
|
||||
rc = LBER_DEFAULT;
|
||||
}
|
||||
if ( j > 0 )
|
||||
(*sss)[j] = NULL;
|
||||
break;
|
||||
|
||||
case 'V': /* sequence of strings + lengths */
|
||||
bv = va_arg( ap, struct berval *** );
|
||||
*bv = NULL;
|
||||
j = 0;
|
||||
for ( tag = ber_first_element( ber, &len, &last );
|
||||
tag != LBER_DEFAULT && tag != LBER_END_OF_SEQORSET
|
||||
&& rc != LBER_DEFAULT;
|
||||
tag = ber_next_element( ber, &len, last ) ) {
|
||||
if ( *bv == NULL ) {
|
||||
*bv = (struct berval **)NSLBERI_MALLOC(
|
||||
2 * sizeof(struct berval *) );
|
||||
} else {
|
||||
*bv = (struct berval **)NSLBERI_REALLOC(
|
||||
*bv,
|
||||
(j + 2) * sizeof(struct berval *) );
|
||||
}
|
||||
rc = ber_get_stringal( ber, &((*bv)[j]) );
|
||||
j++;
|
||||
}
|
||||
if ( rc != LBER_DEFAULT &&
|
||||
tag != LBER_END_OF_SEQORSET ) {
|
||||
rc = LBER_DEFAULT;
|
||||
}
|
||||
if ( j > 0 )
|
||||
(*bv)[j] = NULL;
|
||||
break;
|
||||
|
||||
case 'x': /* skip the next element - whatever it is */
|
||||
if ( (rc = ber_skip_tag( ber, &len )) == LBER_DEFAULT )
|
||||
break;
|
||||
ber->ber_ptr += len;
|
||||
break;
|
||||
|
||||
case '{': /* begin sequence */
|
||||
case '[': /* begin set */
|
||||
if ( *(fmt + 1) != 'v' && *(fmt + 1) != 'V' )
|
||||
rc = ber_skip_tag( ber, &len );
|
||||
break;
|
||||
|
||||
case '}': /* end sequence */
|
||||
case ']': /* end set */
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
char msg[80];
|
||||
sprintf( msg, "unknown fmt %c\n", *fmt );
|
||||
ber_err_print( msg );
|
||||
}
|
||||
rc = LBER_DEFAULT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
va_end( ap );
|
||||
|
||||
return( rc );
|
||||
}
|
||||
|
||||
void
|
||||
LDAP_CALL
|
||||
ber_bvfree( struct berval *bv )
|
||||
{
|
||||
if ( bv != NULL ) {
|
||||
if ( bv->bv_val != NULL ) {
|
||||
NSLBERI_FREE( bv->bv_val );
|
||||
}
|
||||
NSLBERI_FREE( (char *) bv );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LDAP_CALL
|
||||
ber_bvecfree( struct berval **bv )
|
||||
{
|
||||
int i;
|
||||
|
||||
for ( i = 0; bv[i] != NULL; i++ ) {
|
||||
ber_bvfree( bv[i] );
|
||||
}
|
||||
NSLBERI_FREE( (char *) bv );
|
||||
}
|
||||
|
||||
struct berval *
|
||||
LDAP_CALL
|
||||
ber_bvdup( struct berval *bv )
|
||||
{
|
||||
struct berval *new;
|
||||
|
||||
if ( (new = (struct berval *)NSLBERI_MALLOC( sizeof(struct berval) ))
|
||||
== NULL ) {
|
||||
return( NULL );
|
||||
}
|
||||
if ( bv->bv_val == NULL ) {
|
||||
new->bv_val = NULL;
|
||||
new->bv_len = 0;
|
||||
} else {
|
||||
if ( (new->bv_val = (char *)NSLBERI_MALLOC( bv->bv_len + 1 ))
|
||||
== NULL ) {
|
||||
return( NULL );
|
||||
}
|
||||
SAFEMEMCPY( new->bv_val, bv->bv_val, (size_t) bv->bv_len );
|
||||
new->bv_val[bv->bv_len] = '\0';
|
||||
new->bv_len = bv->bv_len;
|
||||
}
|
||||
|
||||
return( new );
|
||||
}
|
||||
|
||||
|
||||
#ifdef STR_TRANSLATION
|
||||
void
|
||||
LDAP_CALL
|
||||
ber_set_string_translators(
|
||||
BerElement *ber,
|
||||
BERTranslateProc encode_proc,
|
||||
BERTranslateProc decode_proc
|
||||
)
|
||||
{
|
||||
ber->ber_encode_translate_proc = encode_proc;
|
||||
ber->ber_decode_translate_proc = decode_proc;
|
||||
}
|
||||
#endif /* STR_TRANSLATION */
|
||||
94
mozilla/directory/c-sdk/ldap/libraries/liblber/dtest.c
Normal file
@@ -0,0 +1,94 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990 Regents of the University of Michigan.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that this notice is preserved and that due credit is given
|
||||
* to the University of Michigan at Ann Arbor. The name of the University
|
||||
* may not be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission. This software
|
||||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
/* dtest.c - lber decoding test program */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef MACOS
|
||||
#include <stdlib.h>
|
||||
#include <console.h>
|
||||
#else /* MACOS */
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#endif /* _WIN32 */
|
||||
#endif /* MACOS */
|
||||
#include "lber.h"
|
||||
|
||||
int
|
||||
SSL_Recv( int s, char *b, unsigned l, int dummy )
|
||||
{
|
||||
return( read( s, b, l ) );
|
||||
}
|
||||
|
||||
SSL_Send( int s, char *b, unsigned l, int dummy )
|
||||
{
|
||||
return( write( s, b, l ) );
|
||||
}
|
||||
|
||||
static void usage( char *name )
|
||||
{
|
||||
fprintf( stderr, "usage: %s < berfile\n", name );
|
||||
}
|
||||
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
long i, fd;
|
||||
unsigned long len;
|
||||
int tag;
|
||||
BerElement *ber;
|
||||
Sockbuf *sb;
|
||||
extern int lber_debug;
|
||||
|
||||
lber_debug = 255;
|
||||
if ( argc > 1 ) {
|
||||
usage( argv[0] );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
sb = ber_sockbuf_alloc();
|
||||
fd = 0;
|
||||
ber_sockbuf_set_option( sb, LBER_SOCKBUF_OPT_DESC, &fd );
|
||||
|
||||
if ( (ber = der_alloc()) == NULL ) {
|
||||
perror( "ber_alloc" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
if ( (tag = ber_get_next( sb, &len, ber )) == LBER_ERROR ) {
|
||||
perror( "ber_get_next" );
|
||||
exit( 1 );
|
||||
}
|
||||
printf( "message has tag 0x%x and length %ld\n", tag, len );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
656
mozilla/directory/c-sdk/ldap/libraries/liblber/encode.c
Normal file
@@ -0,0 +1,656 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990 Regents of the University of Michigan.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that this notice is preserved and that due credit is given
|
||||
* to the University of Michigan at Ann Arbor. The name of the University
|
||||
* may not be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission. This software
|
||||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
|
||||
/* encode.c - ber output encoding routines */
|
||||
|
||||
#include "lber-int.h"
|
||||
|
||||
static int
|
||||
ber_calc_taglen( unsigned long tag )
|
||||
{
|
||||
int i;
|
||||
long mask;
|
||||
|
||||
/* find the first non-all-zero byte in the tag */
|
||||
for ( i = sizeof(long) - 1; i > 0; i-- ) {
|
||||
mask = (0xffL << (i * 8));
|
||||
/* not all zero */
|
||||
if ( tag & mask )
|
||||
break;
|
||||
}
|
||||
|
||||
return( i + 1 );
|
||||
}
|
||||
|
||||
static int
|
||||
ber_put_tag( BerElement *ber, unsigned long tag, int nosos )
|
||||
{
|
||||
int taglen;
|
||||
unsigned long ntag;
|
||||
|
||||
taglen = ber_calc_taglen( tag );
|
||||
|
||||
ntag = LBER_HTONL( tag );
|
||||
|
||||
return( ber_write( ber, ((char *) &ntag) + sizeof(long) - taglen,
|
||||
taglen, nosos ) );
|
||||
}
|
||||
|
||||
static int
|
||||
ber_calc_lenlen( unsigned long len )
|
||||
{
|
||||
/*
|
||||
* short len if it's less than 128 - one byte giving the len,
|
||||
* with bit 8 0.
|
||||
*/
|
||||
|
||||
if ( len <= 0x7F )
|
||||
return( 1 );
|
||||
|
||||
/*
|
||||
* long len otherwise - one byte with bit 8 set, giving the
|
||||
* length of the length, followed by the length itself.
|
||||
*/
|
||||
|
||||
if ( len <= 0xFF )
|
||||
return( 2 );
|
||||
if ( len <= 0xFFFFL )
|
||||
return( 3 );
|
||||
if ( len <= 0xFFFFFFL )
|
||||
return( 4 );
|
||||
|
||||
return( 5 );
|
||||
}
|
||||
|
||||
static int
|
||||
ber_put_len( BerElement *ber, unsigned long len, int nosos )
|
||||
{
|
||||
int i;
|
||||
char lenlen;
|
||||
long mask;
|
||||
unsigned long netlen;
|
||||
|
||||
/*
|
||||
* short len if it's less than 128 - one byte giving the len,
|
||||
* with bit 8 0.
|
||||
*/
|
||||
|
||||
if ( len <= 127 ) {
|
||||
netlen = LBER_HTONL( len );
|
||||
return( ber_write( ber, (char *) &netlen + sizeof(long) - 1,
|
||||
1, nosos ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* long len otherwise - one byte with bit 8 set, giving the
|
||||
* length of the length, followed by the length itself.
|
||||
*/
|
||||
|
||||
/* find the first non-all-zero byte */
|
||||
for ( i = sizeof(long) - 1; i > 0; i-- ) {
|
||||
mask = (0xffL << (i * 8));
|
||||
/* not all zero */
|
||||
if ( len & mask )
|
||||
break;
|
||||
}
|
||||
lenlen = ++i;
|
||||
if ( lenlen > 4 )
|
||||
return( -1 );
|
||||
lenlen |= 0x80;
|
||||
|
||||
/* write the length of the length */
|
||||
if ( ber_write( ber, &lenlen, 1, nosos ) != 1 )
|
||||
return( -1 );
|
||||
|
||||
/* write the length itself */
|
||||
netlen = LBER_HTONL( len );
|
||||
if ( ber_write( ber, (char *) &netlen + (sizeof(long) - i), i, nosos )
|
||||
!= i )
|
||||
return( -1 );
|
||||
|
||||
return( i + 1 );
|
||||
}
|
||||
|
||||
static int
|
||||
ber_put_int_or_enum( BerElement *ber, long num, unsigned long tag )
|
||||
{
|
||||
int i, sign, taglen;
|
||||
int len, lenlen;
|
||||
long netnum, mask;
|
||||
|
||||
sign = (num < 0);
|
||||
|
||||
/*
|
||||
* high bit is set - look for first non-all-one byte
|
||||
* high bit is clear - look for first non-all-zero byte
|
||||
*/
|
||||
for ( i = sizeof(long) - 1; i > 0; i-- ) {
|
||||
mask = (0xffL << (i * 8));
|
||||
|
||||
if ( sign ) {
|
||||
/* not all ones */
|
||||
if ( (num & mask) != mask )
|
||||
break;
|
||||
} else {
|
||||
/* not all zero */
|
||||
if ( num & mask )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* we now have the "leading byte". if the high bit on this
|
||||
* byte matches the sign bit, we need to "back up" a byte.
|
||||
*/
|
||||
mask = (num & (0x80L << (i * 8)));
|
||||
if ( (mask && !sign) || (sign && !mask) )
|
||||
i++;
|
||||
|
||||
len = i + 1;
|
||||
|
||||
if ( (taglen = ber_put_tag( ber, tag, 0 )) == -1 )
|
||||
return( -1 );
|
||||
|
||||
if ( (lenlen = ber_put_len( ber, len, 0 )) == -1 )
|
||||
return( -1 );
|
||||
i++;
|
||||
netnum = LBER_HTONL( num );
|
||||
if ( ber_write( ber, (char *) &netnum + (sizeof(long) - i), i, 0 )
|
||||
== i)
|
||||
/* length of tag + length + contents */
|
||||
return( taglen + lenlen + i );
|
||||
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
int
|
||||
LDAP_CALL
|
||||
ber_put_enum( BerElement *ber, long num, unsigned long tag )
|
||||
{
|
||||
if ( tag == LBER_DEFAULT )
|
||||
tag = LBER_ENUMERATED;
|
||||
|
||||
return( ber_put_int_or_enum( ber, num, tag ) );
|
||||
}
|
||||
|
||||
int
|
||||
LDAP_CALL
|
||||
ber_put_int( BerElement *ber, long num, unsigned long tag )
|
||||
{
|
||||
if ( tag == LBER_DEFAULT )
|
||||
tag = LBER_INTEGER;
|
||||
|
||||
return( ber_put_int_or_enum( ber, num, tag ) );
|
||||
}
|
||||
|
||||
int
|
||||
LDAP_CALL
|
||||
ber_put_ostring( BerElement *ber, char *str, unsigned long len,
|
||||
unsigned long tag )
|
||||
{
|
||||
int taglen, lenlen, rc;
|
||||
#ifdef STR_TRANSLATION
|
||||
int free_str;
|
||||
#endif /* STR_TRANSLATION */
|
||||
|
||||
if ( tag == LBER_DEFAULT )
|
||||
tag = LBER_OCTETSTRING;
|
||||
|
||||
if ( (taglen = ber_put_tag( ber, tag, 0 )) == -1 )
|
||||
return( -1 );
|
||||
|
||||
#ifdef STR_TRANSLATION
|
||||
if ( len > 0 && ( ber->ber_options & LBER_OPT_TRANSLATE_STRINGS ) != 0
|
||||
&& ber->ber_encode_translate_proc != NULL ) {
|
||||
if ( (*(ber->ber_encode_translate_proc))( &str, &len, 0 )
|
||||
!= 0 ) {
|
||||
return( -1 );
|
||||
}
|
||||
free_str = 1;
|
||||
} else {
|
||||
free_str = 0;
|
||||
}
|
||||
#endif /* STR_TRANSLATION */
|
||||
|
||||
if ( (lenlen = ber_put_len( ber, len, 0 )) == -1 ||
|
||||
ber_write( ber, str, len, 0 ) != len ) {
|
||||
rc = -1;
|
||||
} else {
|
||||
/* return length of tag + length + contents */
|
||||
rc = taglen + lenlen + len;
|
||||
}
|
||||
|
||||
#ifdef STR_TRANSLATION
|
||||
if ( free_str ) {
|
||||
NSLBERI_FREE( str );
|
||||
}
|
||||
#endif /* STR_TRANSLATION */
|
||||
|
||||
return( rc );
|
||||
}
|
||||
|
||||
int
|
||||
LDAP_CALL
|
||||
ber_put_string( BerElement *ber, char *str, unsigned long tag )
|
||||
{
|
||||
return( ber_put_ostring( ber, str, strlen( str ), tag ));
|
||||
}
|
||||
|
||||
int
|
||||
LDAP_CALL
|
||||
ber_put_bitstring( BerElement *ber, char *str,
|
||||
unsigned long blen /* in bits */, unsigned long tag )
|
||||
{
|
||||
int taglen, lenlen, len;
|
||||
unsigned char unusedbits;
|
||||
|
||||
if ( tag == LBER_DEFAULT )
|
||||
tag = LBER_BITSTRING;
|
||||
|
||||
if ( (taglen = ber_put_tag( ber, tag, 0 )) == -1 )
|
||||
return( -1 );
|
||||
|
||||
len = ( blen + 7 ) / 8;
|
||||
unusedbits = len * 8 - blen;
|
||||
if ( (lenlen = ber_put_len( ber, len + 1, 0 )) == -1 )
|
||||
return( -1 );
|
||||
|
||||
if ( ber_write( ber, (char *)&unusedbits, 1, 0 ) != 1 )
|
||||
return( -1 );
|
||||
|
||||
if ( ber_write( ber, str, len, 0 ) != len )
|
||||
return( -1 );
|
||||
|
||||
/* return length of tag + length + unused bit count + contents */
|
||||
return( taglen + 1 + lenlen + len );
|
||||
}
|
||||
|
||||
int
|
||||
LDAP_CALL
|
||||
ber_put_null( BerElement *ber, unsigned long tag )
|
||||
{
|
||||
int taglen;
|
||||
|
||||
if ( tag == LBER_DEFAULT )
|
||||
tag = LBER_NULL;
|
||||
|
||||
if ( (taglen = ber_put_tag( ber, tag, 0 )) == -1 )
|
||||
return( -1 );
|
||||
|
||||
if ( ber_put_len( ber, 0, 0 ) != 1 )
|
||||
return( -1 );
|
||||
|
||||
return( taglen + 1 );
|
||||
}
|
||||
|
||||
int
|
||||
LDAP_CALL
|
||||
ber_put_boolean( BerElement *ber, int boolval, unsigned long tag )
|
||||
{
|
||||
int taglen;
|
||||
unsigned char trueval = 0xff;
|
||||
unsigned char falseval = 0x00;
|
||||
|
||||
if ( tag == LBER_DEFAULT )
|
||||
tag = LBER_BOOLEAN;
|
||||
|
||||
if ( (taglen = ber_put_tag( ber, tag, 0 )) == -1 )
|
||||
return( -1 );
|
||||
|
||||
if ( ber_put_len( ber, 1, 0 ) != 1 )
|
||||
return( -1 );
|
||||
|
||||
if ( ber_write( ber, (char *)(boolval ? &trueval : &falseval), 1, 0 )
|
||||
!= 1 )
|
||||
return( -1 );
|
||||
|
||||
return( taglen + 2 );
|
||||
}
|
||||
|
||||
#define FOUR_BYTE_LEN 5
|
||||
|
||||
|
||||
/* the idea here is roughly this: we maintain a stack of these Seqorset
|
||||
* structures. This is pushed when we see the beginning of a new set or
|
||||
* sequence. It is popped when we see the end of a set or sequence.
|
||||
* Since we don't want to malloc and free these structures all the time,
|
||||
* we pre-allocate a small set of them within the ber element structure.
|
||||
* thus we need to spot when we've overflowed this stack and fall back to
|
||||
* malloc'ing instead.
|
||||
*/
|
||||
static int
|
||||
ber_start_seqorset( BerElement *ber, unsigned long tag )
|
||||
{
|
||||
Seqorset *new_sos;
|
||||
|
||||
/* can we fit into the local stack ? */
|
||||
if (ber->ber_sos_stack_posn < SOS_STACK_SIZE) {
|
||||
/* yes */
|
||||
new_sos = &ber->ber_sos_stack[ber->ber_sos_stack_posn];
|
||||
} else {
|
||||
/* no */
|
||||
if ( (new_sos = (Seqorset *)NSLBERI_MALLOC( sizeof(Seqorset)))
|
||||
== NULLSEQORSET ) {
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
ber->ber_sos_stack_posn++;
|
||||
|
||||
if ( ber->ber_sos == NULLSEQORSET )
|
||||
new_sos->sos_first = ber->ber_ptr;
|
||||
else
|
||||
new_sos->sos_first = ber->ber_sos->sos_ptr;
|
||||
|
||||
/* Set aside room for a 4 byte length field */
|
||||
new_sos->sos_ptr = new_sos->sos_first + ber_calc_taglen( tag ) + FOUR_BYTE_LEN;
|
||||
new_sos->sos_tag = tag;
|
||||
|
||||
new_sos->sos_next = ber->ber_sos;
|
||||
new_sos->sos_clen = 0;
|
||||
|
||||
ber->ber_sos = new_sos;
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
int
|
||||
LDAP_CALL
|
||||
ber_start_seq( BerElement *ber, unsigned long tag )
|
||||
{
|
||||
if ( tag == LBER_DEFAULT )
|
||||
tag = LBER_SEQUENCE;
|
||||
|
||||
return( ber_start_seqorset( ber, tag ) );
|
||||
}
|
||||
|
||||
int
|
||||
LDAP_CALL
|
||||
ber_start_set( BerElement *ber, unsigned long tag )
|
||||
{
|
||||
if ( tag == LBER_DEFAULT )
|
||||
tag = LBER_SET;
|
||||
|
||||
return( ber_start_seqorset( ber, tag ) );
|
||||
}
|
||||
|
||||
static int
|
||||
ber_put_seqorset( BerElement *ber )
|
||||
{
|
||||
unsigned long len, netlen;
|
||||
int taglen, lenlen;
|
||||
unsigned char ltag = 0x80 + FOUR_BYTE_LEN - 1;
|
||||
Seqorset *next;
|
||||
Seqorset **sos = &ber->ber_sos;
|
||||
|
||||
/*
|
||||
* If this is the toplevel sequence or set, we need to actually
|
||||
* write the stuff out. Otherwise, it's already been put in
|
||||
* the appropriate buffer and will be written when the toplevel
|
||||
* one is written. In this case all we need to do is update the
|
||||
* length and tag.
|
||||
*/
|
||||
|
||||
len = (*sos)->sos_clen;
|
||||
netlen = LBER_HTONL( len );
|
||||
if ( sizeof(long) > 4 && len > 0xFFFFFFFFL )
|
||||
return( -1 );
|
||||
|
||||
if ( ber->ber_options & LBER_OPT_USE_DER ) {
|
||||
lenlen = ber_calc_lenlen( len );
|
||||
} else {
|
||||
lenlen = FOUR_BYTE_LEN;
|
||||
}
|
||||
|
||||
if ( (next = (*sos)->sos_next) == NULLSEQORSET ) {
|
||||
/* write the tag */
|
||||
if ( (taglen = ber_put_tag( ber, (*sos)->sos_tag, 1 )) == -1 )
|
||||
return( -1 );
|
||||
|
||||
if ( ber->ber_options & LBER_OPT_USE_DER ) {
|
||||
/* Write the length in the minimum # of octets */
|
||||
if ( ber_put_len( ber, len, 1 ) == -1 )
|
||||
return( -1 );
|
||||
|
||||
if (lenlen != FOUR_BYTE_LEN) {
|
||||
/*
|
||||
* We set aside FOUR_BYTE_LEN bytes for
|
||||
* the length field. Move the data if
|
||||
* we don't actually need that much
|
||||
*/
|
||||
SAFEMEMCPY( (*sos)->sos_first + taglen +
|
||||
lenlen, (*sos)->sos_first + taglen +
|
||||
FOUR_BYTE_LEN, len );
|
||||
}
|
||||
} else {
|
||||
/* Fill FOUR_BYTE_LEN bytes for length field */
|
||||
/* one byte of length length */
|
||||
if ( ber_write( ber, (char *)<ag, 1, 1 ) != 1 )
|
||||
return( -1 );
|
||||
|
||||
/* the length itself */
|
||||
if ( ber_write( ber, (char *) &netlen + sizeof(long)
|
||||
- (FOUR_BYTE_LEN - 1), FOUR_BYTE_LEN - 1, 1 )
|
||||
!= FOUR_BYTE_LEN - 1 )
|
||||
return( -1 );
|
||||
}
|
||||
/* The ber_ptr is at the set/seq start - move it to the end */
|
||||
ber->ber_ptr += len;
|
||||
} else {
|
||||
unsigned long ntag;
|
||||
|
||||
/* the tag */
|
||||
taglen = ber_calc_taglen( (*sos)->sos_tag );
|
||||
ntag = LBER_HTONL( (*sos)->sos_tag );
|
||||
SAFEMEMCPY( (*sos)->sos_first, (char *) &ntag +
|
||||
sizeof(long) - taglen, taglen );
|
||||
|
||||
if ( ber->ber_options & LBER_OPT_USE_DER ) {
|
||||
ltag = (lenlen == 1) ? len : 0x80 + (lenlen - 1);
|
||||
}
|
||||
|
||||
/* one byte of length length */
|
||||
SAFEMEMCPY( (*sos)->sos_first + 1, <ag, 1 );
|
||||
|
||||
if ( ber->ber_options & LBER_OPT_USE_DER ) {
|
||||
if (lenlen > 1) {
|
||||
/* Write the length itself */
|
||||
SAFEMEMCPY( (*sos)->sos_first + 2,
|
||||
(char *)&netlen + sizeof(unsigned long) -
|
||||
(lenlen - 1),
|
||||
lenlen - 1 );
|
||||
}
|
||||
if (lenlen != FOUR_BYTE_LEN) {
|
||||
/*
|
||||
* We set aside FOUR_BYTE_LEN bytes for
|
||||
* the length field. Move the data if
|
||||
* we don't actually need that much
|
||||
*/
|
||||
SAFEMEMCPY( (*sos)->sos_first + taglen +
|
||||
lenlen, (*sos)->sos_first + taglen +
|
||||
FOUR_BYTE_LEN, len );
|
||||
}
|
||||
} else {
|
||||
/* the length itself */
|
||||
SAFEMEMCPY( (*sos)->sos_first + taglen + 1,
|
||||
(char *) &netlen + sizeof(long) -
|
||||
(FOUR_BYTE_LEN - 1), FOUR_BYTE_LEN - 1 );
|
||||
}
|
||||
|
||||
next->sos_clen += (taglen + lenlen + len);
|
||||
next->sos_ptr += (taglen + lenlen + len);
|
||||
}
|
||||
|
||||
/* we're done with this seqorset, so free it up */
|
||||
/* was this one from the local stack ? */
|
||||
if (ber->ber_sos_stack_posn <= SOS_STACK_SIZE) {
|
||||
/* yes */
|
||||
} else {
|
||||
/* no */
|
||||
NSLBERI_FREE( (char *) (*sos) );
|
||||
}
|
||||
ber->ber_sos_stack_posn--;
|
||||
*sos = next;
|
||||
|
||||
return( taglen + lenlen + len );
|
||||
}
|
||||
|
||||
int
|
||||
LDAP_CALL
|
||||
ber_put_seq( BerElement *ber )
|
||||
{
|
||||
return( ber_put_seqorset( ber ) );
|
||||
}
|
||||
|
||||
int
|
||||
LDAP_CALL
|
||||
ber_put_set( BerElement *ber )
|
||||
{
|
||||
return( ber_put_seqorset( ber ) );
|
||||
}
|
||||
|
||||
/* VARARGS */
|
||||
int
|
||||
LDAP_C
|
||||
ber_printf( BerElement *ber, char *fmt, ... )
|
||||
{
|
||||
va_list ap;
|
||||
char *s, **ss;
|
||||
struct berval **bv;
|
||||
int rc, i;
|
||||
unsigned long len;
|
||||
|
||||
va_start( ap, fmt );
|
||||
|
||||
#ifdef LDAP_DEBUG
|
||||
if ( lber_debug & 64 ) {
|
||||
char msg[80];
|
||||
sprintf( msg, "ber_printf fmt (%s)\n", fmt );
|
||||
ber_err_print( msg );
|
||||
}
|
||||
#endif
|
||||
|
||||
for ( rc = 0; *fmt && rc != -1; fmt++ ) {
|
||||
switch ( *fmt ) {
|
||||
case 'b': /* boolean */
|
||||
i = va_arg( ap, int );
|
||||
rc = ber_put_boolean( ber, i, ber->ber_tag );
|
||||
break;
|
||||
|
||||
case 'i': /* int */
|
||||
i = va_arg( ap, int );
|
||||
rc = ber_put_int( ber, i, ber->ber_tag );
|
||||
break;
|
||||
|
||||
case 'e': /* enumeration */
|
||||
i = va_arg( ap, int );
|
||||
rc = ber_put_enum( ber, i, ber->ber_tag );
|
||||
break;
|
||||
|
||||
case 'n': /* null */
|
||||
rc = ber_put_null( ber, ber->ber_tag );
|
||||
break;
|
||||
|
||||
case 'o': /* octet string (non-null terminated) */
|
||||
s = va_arg( ap, char * );
|
||||
len = va_arg( ap, int );
|
||||
rc = ber_put_ostring( ber, s, len, ber->ber_tag );
|
||||
break;
|
||||
|
||||
case 's': /* string */
|
||||
s = va_arg( ap, char * );
|
||||
rc = ber_put_string( ber, s, ber->ber_tag );
|
||||
break;
|
||||
|
||||
case 'B': /* bit string */
|
||||
s = va_arg( ap, char * );
|
||||
len = va_arg( ap, int ); /* in bits */
|
||||
rc = ber_put_bitstring( ber, s, len, ber->ber_tag );
|
||||
break;
|
||||
|
||||
case 't': /* tag for the next element */
|
||||
ber->ber_tag = va_arg( ap, unsigned long );
|
||||
ber->ber_usertag = 1;
|
||||
break;
|
||||
|
||||
case 'v': /* vector of strings */
|
||||
if ( (ss = va_arg( ap, char ** )) == NULL )
|
||||
break;
|
||||
for ( i = 0; ss[i] != NULL; i++ ) {
|
||||
if ( (rc = ber_put_string( ber, ss[i],
|
||||
ber->ber_tag )) == -1 )
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'V': /* sequences of strings + lengths */
|
||||
if ( (bv = va_arg( ap, struct berval ** )) == NULL )
|
||||
break;
|
||||
for ( i = 0; bv[i] != NULL; i++ ) {
|
||||
if ( (rc = ber_put_ostring( ber, bv[i]->bv_val,
|
||||
bv[i]->bv_len, ber->ber_tag )) == -1 )
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case '{': /* begin sequence */
|
||||
rc = ber_start_seq( ber, ber->ber_tag );
|
||||
break;
|
||||
|
||||
case '}': /* end sequence */
|
||||
rc = ber_put_seqorset( ber );
|
||||
break;
|
||||
|
||||
case '[': /* begin set */
|
||||
rc = ber_start_set( ber, ber->ber_tag );
|
||||
break;
|
||||
|
||||
case ']': /* end set */
|
||||
rc = ber_put_seqorset( ber );
|
||||
break;
|
||||
|
||||
default: {
|
||||
char msg[80];
|
||||
sprintf( msg, "unknown fmt %c\n", *fmt );
|
||||
ber_err_print( msg );
|
||||
rc = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ber->ber_usertag == 0 )
|
||||
ber->ber_tag = LBER_DEFAULT;
|
||||
else
|
||||
ber->ber_usertag = 0;
|
||||
}
|
||||
|
||||
va_end( ap );
|
||||
|
||||
return( rc );
|
||||
}
|
||||
168
mozilla/directory/c-sdk/ldap/libraries/liblber/etest.c
Normal file
@@ -0,0 +1,168 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990 Regents of the University of Michigan.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
/* test.c - lber encoding test program */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef MACOS
|
||||
#include <stdlib.h>
|
||||
#include <unix.h>
|
||||
#include <fcntl.h>
|
||||
#include <console.h>
|
||||
#else /* MACOS */
|
||||
#include <sys/types.h>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#endif /* _WIN32 */
|
||||
#endif /* MACOS */
|
||||
#include "lber.h"
|
||||
|
||||
int
|
||||
SSL_Recv( int s, char *b, unsigned l, int dummy )
|
||||
{
|
||||
return( read( s, b, l ) );
|
||||
}
|
||||
|
||||
SSL_Send( int s, char *b, unsigned l, int dummy )
|
||||
{
|
||||
return( write( s, b, l ) );
|
||||
}
|
||||
|
||||
int
|
||||
getline( char *prompt, char c, char *buf, int bsize )
|
||||
{
|
||||
char *p;
|
||||
|
||||
if ( prompt != NULL ) {
|
||||
fprintf( stderr, "%s: ", prompt );
|
||||
} else {
|
||||
fprintf( stderr, "enter value for '%c': ", c );
|
||||
}
|
||||
if ( fgets( buf, bsize, stdin ) == NULL ) {
|
||||
return( -1 );
|
||||
}
|
||||
if ( (p = strchr( buf, '\n' )) != NULL ) {
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
static void usage( char *name )
|
||||
{
|
||||
fprintf( stderr, "usage: %s fmtstring\n", name );
|
||||
}
|
||||
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
int rc, fd;
|
||||
char *s, *p;
|
||||
void *arg1, *arg2;
|
||||
Sockbuf *sb;
|
||||
BerElement *ber;
|
||||
char fmt[2];
|
||||
char buf[BUFSIZ];
|
||||
extern int lber_debug;
|
||||
|
||||
lber_debug = 255;
|
||||
if ( argc < 2 ) {
|
||||
usage( argv[0] );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
sb = ber_sockbuf_alloc();
|
||||
fd = 1;
|
||||
ber_sockbuf_set_option( sb, LBER_SOCKBUF_OPT_DESC, &fd );
|
||||
|
||||
if ( (ber = der_alloc()) == NULL ) {
|
||||
perror( "ber_alloc" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
rc = 0;
|
||||
fmt[1] = '\0';
|
||||
for ( s = argv[1]; *s; s++ ) {
|
||||
switch ( *s ) {
|
||||
case 'i': /* int */
|
||||
case 'b': /* boolean */
|
||||
case 'e': /* enumeration */
|
||||
getline( NULL, *s, buf, sizeof(buf) );
|
||||
arg1 = (void *) atoi( buf );
|
||||
break;
|
||||
|
||||
case 'n': /* null */
|
||||
arg1 = NULL;
|
||||
break;
|
||||
|
||||
case 'o': /* octet string (non-null terminated) */
|
||||
getline( NULL, *s, buf, sizeof(buf) );
|
||||
arg1 = (void *) buf;
|
||||
arg2 = (void *) strlen( buf );
|
||||
break;
|
||||
|
||||
case 's': /* string */
|
||||
getline( NULL, *s, buf, sizeof(buf) );
|
||||
arg1 = (void *) buf;
|
||||
break;
|
||||
|
||||
case 'B': /* bit string */
|
||||
getline( NULL, *s, buf, sizeof(buf) );
|
||||
arg1 = (void *) buf;
|
||||
arg2 = (void *) strlen( buf );
|
||||
break;
|
||||
|
||||
case 't': /* tag for the next element */
|
||||
getline( NULL, *s, buf, sizeof(buf) );
|
||||
arg1 = (void *) buf;
|
||||
break;
|
||||
|
||||
case '{': /* begin sequence */
|
||||
case '}': /* end sequence */
|
||||
case '[': /* begin set */
|
||||
case ']': /* end set */
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf( stderr, "unknown fmt %c\n", *s );
|
||||
rc = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
fmt[0] = *s;
|
||||
if ( ber_printf( ber, fmt, arg1, arg2 ) == -1 ) {
|
||||
fprintf( stderr, "ber_printf\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ber_flush( sb, ber, 1 ) != 0 ) {
|
||||
perror( "ber_flush" );
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
return( rc );
|
||||
}
|
||||
82
mozilla/directory/c-sdk/ldap/libraries/liblber/idtest.c
Normal file
@@ -0,0 +1,82 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990 Regents of the University of Michigan.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that this notice is preserved and that due credit is given
|
||||
* to the University of Michigan at Ann Arbor. The name of the University
|
||||
* may not be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission. This software
|
||||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
|
||||
/* idtest.c - ber decoding test program using isode libraries */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <psap.h>
|
||||
#include <quipu/attr.h>
|
||||
|
||||
static usage( char *name )
|
||||
{
|
||||
fprintf( stderr, "usage: %s\n", name );
|
||||
}
|
||||
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
PE pe;
|
||||
PS psin, psout, pserr;
|
||||
|
||||
/* read the pe from standard in */
|
||||
if ( (psin = ps_alloc( std_open )) == NULLPS ) {
|
||||
perror( "ps_alloc" );
|
||||
exit( 1 );
|
||||
}
|
||||
if ( std_setup( psin, stdin ) == NOTOK ) {
|
||||
perror( "std_setup" );
|
||||
exit( 1 );
|
||||
}
|
||||
/* write the pe to standard out */
|
||||
if ( (psout = ps_alloc( std_open )) == NULLPS ) {
|
||||
perror( "ps_alloc" );
|
||||
exit( 1 );
|
||||
}
|
||||
if ( std_setup( psout, stdout ) == NOTOK ) {
|
||||
perror( "std_setup" );
|
||||
exit( 1 );
|
||||
}
|
||||
/* pretty print it to standard error */
|
||||
if ( (pserr = ps_alloc( std_open )) == NULLPS ) {
|
||||
perror( "ps_alloc" );
|
||||
exit( 1 );
|
||||
}
|
||||
if ( std_setup( pserr, stderr ) == NOTOK ) {
|
||||
perror( "std_setup" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
while ( (pe = ps2pe( psin )) != NULLPE ) {
|
||||
pe2pl( pserr, pe );
|
||||
pe2ps( psout, pe );
|
||||
}
|
||||
|
||||
exit( 0 );
|
||||
}
|
||||
1188
mozilla/directory/c-sdk/ldap/libraries/liblber/io.c
Normal file
231
mozilla/directory/c-sdk/ldap/libraries/liblber/lber-int.h
Normal file
@@ -0,0 +1,231 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990 Regents of the University of Michigan.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that this notice is preserved and that due credit is given
|
||||
* to the University of Michigan at Ann Arbor. The name of the University
|
||||
* may not be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission. This software
|
||||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
/* lbet-int.h - internal header file for liblber */
|
||||
|
||||
#ifndef _LBERINT_H
|
||||
#define _LBERINT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef macintosh
|
||||
# include "ldap-macos.h"
|
||||
#else /* macintosh */
|
||||
#if !defined(BSDI)
|
||||
# include <malloc.h>
|
||||
#endif
|
||||
# include <errno.h>
|
||||
# include <sys/types.h>
|
||||
#if defined(SUNOS4) || defined(SCOOS)
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
#if defined( _WINDOWS )
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
# include <time.h>
|
||||
/* No stderr in a 16-bit Windows DLL */
|
||||
# if defined(_WINDLL) && !defined(_WIN32)
|
||||
# define USE_DBG_WIN
|
||||
# endif
|
||||
# else
|
||||
#if !defined(XP_OS2)
|
||||
/* # include <sys/varargs.h> */
|
||||
# include <sys/socket.h>
|
||||
# include <netinet/in.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
# endif /* defined( _WINDOWS ) */
|
||||
#endif /* macintosh */
|
||||
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
#include "portable.h"
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <winsock.h>
|
||||
#include <io.h>
|
||||
#endif /* _WINDOWS */
|
||||
|
||||
#ifdef XP_OS2
|
||||
#include <os2sock.h>
|
||||
#include <io.h>
|
||||
#endif /* XP_OS2 */
|
||||
|
||||
/* No stderr in a 16-bit Windows DLL */
|
||||
#if defined(_WINDLL) && !defined(_WIN32)
|
||||
#define stderr NULL
|
||||
#endif
|
||||
|
||||
#include "lber.h"
|
||||
|
||||
#define OLD_LBER_SEQUENCE 0x10L /* w/o constructed bit - broken */
|
||||
#define OLD_LBER_SET 0x11L /* w/o constructed bit - broken */
|
||||
|
||||
#ifndef _IFP
|
||||
#define _IFP
|
||||
typedef int (LDAP_C LDAP_CALLBACK *IFP)();
|
||||
#endif
|
||||
|
||||
extern struct lber_memalloc_fns nslberi_memalloc_fns;
|
||||
|
||||
typedef struct seqorset {
|
||||
unsigned long sos_clen;
|
||||
unsigned long sos_tag;
|
||||
char *sos_first;
|
||||
char *sos_ptr;
|
||||
struct seqorset *sos_next;
|
||||
} Seqorset;
|
||||
#define NULLSEQORSET ((Seqorset *) 0)
|
||||
|
||||
#define SOS_STACK_SIZE 8 /* depth of the pre-allocated sos structure stack */
|
||||
|
||||
struct berelement {
|
||||
char *ber_buf;
|
||||
char *ber_ptr;
|
||||
char *ber_end;
|
||||
struct seqorset *ber_sos;
|
||||
unsigned long ber_tag;
|
||||
unsigned long ber_len;
|
||||
int ber_usertag;
|
||||
char ber_options;
|
||||
char *ber_rwptr;
|
||||
BERTranslateProc ber_encode_translate_proc;
|
||||
BERTranslateProc ber_decode_translate_proc;
|
||||
int ber_flags;
|
||||
#define LBER_FLAG_NO_FREE_BUFFER 1 /* don't free ber_buf */
|
||||
int ber_sos_stack_posn;
|
||||
Seqorset ber_sos_stack[SOS_STACK_SIZE];
|
||||
};
|
||||
#define NULLBER ((BerElement *)NULL)
|
||||
|
||||
struct sockbuf {
|
||||
LBER_SOCKET sb_sd;
|
||||
BerElement sb_ber;
|
||||
int sb_naddr; /* > 0 implies using CLDAP (UDP) */
|
||||
void *sb_useaddr; /* pointer to sockaddr to use next */
|
||||
void *sb_fromaddr; /* pointer to message source sockaddr */
|
||||
void **sb_addrs; /* actually an array of pointers to
|
||||
sockaddrs */
|
||||
|
||||
int sb_options; /* to support copying ber elements */
|
||||
LBER_SOCKET sb_fd;
|
||||
long sb_max_incoming;
|
||||
|
||||
LDAP_IOF_READ_CALLBACK *sb_read_fn;
|
||||
LDAP_IOF_WRITE_CALLBACK *sb_write_fn;
|
||||
};
|
||||
#define NULLSOCKBUF ((Sockbuf *)NULL)
|
||||
#define READBUFSIZ 8192
|
||||
|
||||
|
||||
/*
|
||||
* macros used to check validity of data structures and parameters
|
||||
*/
|
||||
#define NSLBERI_VALID_BERELEMENT_POINTER( ber ) \
|
||||
( (ber) != NULLBER )
|
||||
|
||||
#define NSLBERI_VALID_SOCKBUF_POINTER( sb ) \
|
||||
( (sb) != NULLSOCKBUF )
|
||||
|
||||
|
||||
#if defined(_WIN32) && defined(_ALPHA)
|
||||
#define LBER_HTONL( _l ) \
|
||||
((((_l)&0xff)<<24) + (((_l)&0xff00)<<8) + \
|
||||
(((_l)&0xff0000)>>8) + (((_l)&0xff000000)>>24))
|
||||
#define LBER_NTOHL(_l) LBER_HTONL(_l)
|
||||
|
||||
#elif !defined(__alpha) || defined(VMS)
|
||||
|
||||
#define LBER_HTONL( l ) htonl( l )
|
||||
#define LBER_NTOHL( l ) ntohl( l )
|
||||
|
||||
#else /* __alpha */
|
||||
/*
|
||||
* htonl and ntohl on the DEC Alpha under OSF 1 seem to only swap the
|
||||
* lower-order 32-bits of a (64-bit) long, so we define correct versions
|
||||
* here.
|
||||
*/
|
||||
#define LBER_HTONL( l ) (((long)htonl( (l) & 0x00000000FFFFFFFF )) << 32 \
|
||||
| htonl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
|
||||
|
||||
#define LBER_NTOHL( l ) (((long)ntohl( (l) & 0x00000000FFFFFFFF )) << 32 \
|
||||
| ntohl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
|
||||
#endif /* __alpha */
|
||||
|
||||
|
||||
/* function prototypes */
|
||||
#ifdef LDAP_DEBUG
|
||||
void ber_dump( BerElement *ber, int inout );
|
||||
void lber_bprint( char *data, int len );
|
||||
#endif
|
||||
void ber_err_print( char *data );
|
||||
void *nslberi_malloc( size_t size );
|
||||
void *nslberi_calloc( size_t nelem, size_t elsize );
|
||||
void *nslberi_realloc( void *ptr, size_t size );
|
||||
void nslberi_free( void *ptr );
|
||||
|
||||
|
||||
/* blame: dboreham
|
||||
* slapd spends much of its time doing memcpy's for the ber code.
|
||||
* Most of these are single-byte, so we special-case those and speed
|
||||
* things up considerably.
|
||||
*/
|
||||
|
||||
#ifdef sunos4
|
||||
#define THEMEMCPY( d, s, n ) bcopy( s, d, n )
|
||||
#else /* sunos4 */
|
||||
#define THEMEMCPY( d, s, n ) memmove( d, s, n )
|
||||
#endif /* sunos4 */
|
||||
|
||||
#ifdef SAFEMEMCPY
|
||||
#undef SAFEMEMCPY
|
||||
#define SAFEMEMCPY(d,s,n) if (1 == n) *((char*)d) = *((char*)s); else THEMEMCPY(d,s,n);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Memory allocation done in liblber should all go through one of the
|
||||
* following macros. This is so we can plug-in alternative memory
|
||||
* allocators, etc. as the need arises.
|
||||
*/
|
||||
#define NSLBERI_MALLOC( size ) nslberi_malloc( size )
|
||||
#define NSLBERI_CALLOC( nelem, elsize ) nslberi_calloc( nelem, elsize )
|
||||
#define NSLBERI_REALLOC( ptr, size ) nslberi_realloc( ptr, size )
|
||||
#define NSLBERI_FREE( ptr ) nslberi_free( ptr )
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _LBERINT_H */
|
||||
162
mozilla/directory/c-sdk/ldap/libraries/libldap/Makefile.client
Normal file
@@ -0,0 +1,162 @@
|
||||
DEPTH = ../../../../..
|
||||
NS_DEPTH = ../../../..
|
||||
LDAPSRC = ../..
|
||||
|
||||
RM = rm -f
|
||||
SED = sed
|
||||
|
||||
SRCS = abandon.c \
|
||||
add.c \
|
||||
bind.c \
|
||||
cache.c \
|
||||
charray.c \
|
||||
charset.c \
|
||||
compare.c \
|
||||
compat.c \
|
||||
control.c \
|
||||
countvalues.c \
|
||||
delete.c \
|
||||
disptmpl.c \
|
||||
dsparse.c \
|
||||
error.c \
|
||||
extendop.c \
|
||||
free.c \
|
||||
freevalues.c \
|
||||
friendly.c \
|
||||
getattr.c \
|
||||
getdn.c \
|
||||
getdxbyname.c \
|
||||
getentry.c \
|
||||
getfilter.c \
|
||||
getoption.c \
|
||||
getvalues.c \
|
||||
memcache.c \
|
||||
message.c \
|
||||
modify.c \
|
||||
open.c \
|
||||
os-ip.c \
|
||||
psearch.c \
|
||||
referral.c \
|
||||
regex.c \
|
||||
rename.c \
|
||||
request.c \
|
||||
reslist.c \
|
||||
result.c \
|
||||
saslbind.c \
|
||||
sbind.c \
|
||||
search.c \
|
||||
setoption.c \
|
||||
sort.c \
|
||||
sortctrl.c \
|
||||
srchpref.c \
|
||||
tmplout.c \
|
||||
ufn.c \
|
||||
unbind.c \
|
||||
unescape.c \
|
||||
url.c \
|
||||
utf8.c \
|
||||
vlistctrl.c
|
||||
|
||||
REALOBJS = $(SRCS:.c=.o)
|
||||
|
||||
#OBJS = $(REALOBJS) versiont.o
|
||||
OBJS = $(REALOBJS)
|
||||
|
||||
HDIR = $(LDAPSRC)/include
|
||||
|
||||
CFLAGS = $(INCLUDES) $(DEFINES)
|
||||
|
||||
LIBRARY_NAME = ldap
|
||||
|
||||
#
|
||||
# DEFS are included in CFLAGS
|
||||
#
|
||||
DEFS = $(PLATFORMCFLAGS) $(LDAP_DEBUG) $(KERBEROS) $(AFSKERBEROS) \
|
||||
$(UOFM) $(UOFA) $(NO_USERINTERFACE) $(CLDAP) $(NO_CACHE) \
|
||||
$(LDAP_REFERRALS) $(LDAP_DNS) $(STR_TRANSLATION) \
|
||||
$(LIBLDAP_CHARSETS) $(LIBLDAP_DEF_CHARSET) \
|
||||
$(SLAPD_BACKENDS) $(LDBMBACKEND) $(LDBMINCLUDE) $(PHONETIC) \
|
||||
$(LDAP_SSLIO_HOOKS)
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
LOCAL_INCLUDES = -I$(PUBLIC)/nspr
|
||||
INCLUDES += -I$(HDIR) $(KRBINCLUDEFLAG)
|
||||
DEFINES += $(DEFS) -DFILTERFILE="\"$(RUNTIMEETCDIR)/ldapfilter.conf\"" \
|
||||
-DTEMPLATEFILE="\"$(RUNTIMEETCDIR)/ldaptemplates.conf\"" \
|
||||
-DNET_SSL -UMOZILLA_CLIENT
|
||||
|
||||
# So we actually get the definition of hostent_data....
|
||||
ifeq ($(OS_ARCH),AIX)
|
||||
DEFINES += -D_THREAD_SAFE
|
||||
endif
|
||||
|
||||
GARBAGE += $(ETCDIR)/ldapfriendly $(ETCDIR)/ldapfilter.conf \
|
||||
$(ETCDIR)/ldaptemplates.conf $(ETCDIR)/ldapsearchprefs.conf
|
||||
|
||||
PLATFORMCFLAGS = -DUSE_WAITPID -DNEEDPROTOS
|
||||
PLATFORMLIBS =
|
||||
THREADS =
|
||||
THREADSLIB =
|
||||
|
||||
ETCFILES = ldapfilter.conf \
|
||||
ldapfriendly \
|
||||
ldapsearchprefs.conf \
|
||||
ldaptemplates.conf \
|
||||
$(NULL)
|
||||
|
||||
ETCDIR = $(DIST)/etc
|
||||
|
||||
#
|
||||
# if you want things to run in a different directory from where they
|
||||
# are installed, set this accordingly (this path gets compiled into a
|
||||
# few binaries). otherwise, leave it alone.
|
||||
#
|
||||
RUNTIMEETCDIR = $(ETCDIR)
|
||||
|
||||
#
|
||||
# To build slapd (the stand-alone ldap daemon), uncomment the MAKESLAPD
|
||||
# line and select the SLAPD_BACKENDS you want to use. If you enable the
|
||||
# LDBM backend, also select one of the LDBM backends.
|
||||
#
|
||||
MAKESLAPD = yes
|
||||
SLAPD_BACKENDS = -DLDAP_LDBM -DLDAP_SHELL -DLDAP_PASSWD
|
||||
LDBMBACKEND = -DLDBM_USE_NDBM
|
||||
|
||||
#
|
||||
# uncomment this line to enable debugging code (a good idea)
|
||||
#
|
||||
ifndef BUILD_OPT
|
||||
LDAP_DEBUG = -DLDAP_DEBUG
|
||||
endif
|
||||
|
||||
#
|
||||
# uncomment this line to enable support for LDAP referrals in libldap
|
||||
#
|
||||
LDAP_REFERRALS = -DLDAP_REFERRALS
|
||||
|
||||
#
|
||||
# uncomment this line to enable support for SSL I/O in libldap
|
||||
#
|
||||
LDAP_SSLIO_HOOKS = -DLDAP_SSLIO_HOOKS
|
||||
|
||||
|
||||
###########################################################################
|
||||
|
||||
versiont.c: Makefile.client Version.c
|
||||
@$(RM) $@
|
||||
@(u="$${USER-root}" v="$(shell cat ../../build/version)" d="$(shell pwd)" \
|
||||
h="$(shell hostname)" t="$(shell date)"; $(SED) -e "s|%WHEN%|$${t}|" \
|
||||
-e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \
|
||||
-e "s|%VERSION%|$${v}|" \
|
||||
< Version.c > $@)
|
||||
|
||||
$(LIBRARY): $(OBJS)
|
||||
|
||||
install:: $(LIBRARY) $(ETCFILES)
|
||||
$(INSTALL) -m 444 $(LIBRARY) $(DIST)/ldap/lib
|
||||
ifdef MKSHLIB
|
||||
$(INSTALL) -m 555 $(SHARED_LIBRARY) $(DIST)/ldap/bin
|
||||
endif
|
||||
$(INSTALL) $(INSTALLFLAGS) -m 644 $(ETCFILES) $(ETCDIR)
|
||||
|
||||
224
mozilla/directory/c-sdk/ldap/libraries/libldap/abandon.c
Normal file
@@ -0,0 +1,224 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1990 Regents of the University of Michigan.
|
||||
* All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* abandon.c
|
||||
*/
|
||||
|
||||
#if 0
|
||||
#ifndef lint
|
||||
static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "ldap-int.h"
|
||||
|
||||
static int do_abandon( LDAP *ld, int origid, int msgid,
|
||||
LDAPControl **serverctrls, LDAPControl **clientctrls );
|
||||
|
||||
/*
|
||||
* ldap_abandon - perform an ldap (and X.500) abandon operation. Parameters:
|
||||
*
|
||||
* ld LDAP descriptor
|
||||
* msgid The message id of the operation to abandon
|
||||
*
|
||||
* ldap_abandon returns 0 if everything went ok, -1 otherwise.
|
||||
*
|
||||
* Example:
|
||||
* ldap_abandon( ld, msgid );
|
||||
*/
|
||||
int
|
||||
LDAP_CALL
|
||||
ldap_abandon( LDAP *ld, int msgid )
|
||||
{
|
||||
LDAPDebug( LDAP_DEBUG_TRACE, "ldap_abandon %d\n", msgid, 0, 0 );
|
||||
|
||||
if ( ldap_abandon_ext( ld, msgid, NULL, NULL ) == LDAP_SUCCESS ) {
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* LDAPv3 extended abandon.
|
||||
* Returns an LDAP error code.
|
||||
*/
|
||||
int
|
||||
LDAP_CALL
|
||||
ldap_abandon_ext( LDAP *ld, int msgid, LDAPControl **serverctrls,
|
||||
LDAPControl **clientctrls )
|
||||
{
|
||||
int rc;
|
||||
|
||||
LDAPDebug( LDAP_DEBUG_TRACE, "ldap_abandon_ext %d\n", msgid, 0, 0 );
|
||||
|
||||
if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) {
|
||||
return( LDAP_PARAM_ERROR );
|
||||
}
|
||||
|
||||
LDAP_MUTEX_LOCK( ld, LDAP_REQ_LOCK );
|
||||
LDAP_MUTEX_LOCK( ld, LDAP_CONN_LOCK );
|
||||
rc = do_abandon( ld, msgid, msgid, serverctrls, clientctrls );
|
||||
|
||||
/*
|
||||
* XXXmcs should use cache function pointers to hook in memcache
|
||||
*/
|
||||
ldap_memcache_abandon( ld, msgid );
|
||||
|
||||
LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK );
|
||||
LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK );
|
||||
|
||||
return( rc );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Abandon all outstanding requests for msgid (included child requests
|
||||
* spawned when chasing referrals). This function calls itself recursively.
|
||||
* No locking is done is this function so it must be done by the caller.
|
||||
* Returns an LDAP error code and sets it in LDAP *ld as well
|
||||
*/
|
||||
static int
|
||||
do_abandon( LDAP *ld, int origid, int msgid, LDAPControl **serverctrls,
|
||||
LDAPControl **clientctrls )
|
||||
{
|
||||
BerElement *ber;
|
||||
int i, bererr, lderr, sendabandon;
|
||||
Sockbuf *sb;
|
||||
LDAPRequest *lr;
|
||||
|
||||
/*
|
||||
* An abandon request looks like this:
|
||||
* AbandonRequest ::= MessageID
|
||||
*/
|
||||
LDAPDebug( LDAP_DEBUG_TRACE, "do_abandon origid %d, msgid %d\n",
|
||||
origid, msgid, 0 );
|
||||
|
||||
lderr = LDAP_SUCCESS; /* optimistic */
|
||||
sendabandon = 1;
|
||||
|
||||
/* find the request that we are abandoning */
|
||||
for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) {
|
||||
if ( lr->lr_msgid == msgid ) { /* this message */
|
||||
break;
|
||||
}
|
||||
if ( lr->lr_origid == msgid ) { /* child: abandon it */
|
||||
(void)do_abandon( ld, msgid, lr->lr_msgid,
|
||||
serverctrls, clientctrls );
|
||||
/* we ignore errors from child abandons... */
|
||||
}
|
||||
}
|
||||
|
||||
if ( lr != NULL ) {
|
||||
if ( origid == msgid && lr->lr_parent != NULL ) {
|
||||
/* don't let caller abandon child requests! */
|
||||
lderr = LDAP_PARAM_ERROR;
|
||||
goto set_errorcode_and_return;
|
||||
}
|
||||
if ( lr->lr_status != LDAP_REQST_INPROGRESS ) {
|
||||
/* no need to send abandon message */
|
||||
sendabandon = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ldap_msgdelete( ld, msgid ) == 0 ) {
|
||||
/* we had all the results and deleted them */
|
||||
goto set_errorcode_and_return;
|
||||
}
|
||||
|
||||
if ( sendabandon ) {
|
||||
/* create a message to send */
|
||||
if (( lderr = nsldapi_alloc_ber_with_options( ld, &ber )) ==
|
||||
LDAP_SUCCESS ) {
|
||||
LDAP_MUTEX_LOCK( ld, LDAP_MSGID_LOCK );
|
||||
#ifdef CLDAP
|
||||
if ( ld->ld_dbp->sb_naddr > 0 ) {
|
||||
bererr = ber_printf( ber, "{isti",
|
||||
++ld->ld_msgid, ld->ld_cldapdn,
|
||||
LDAP_REQ_ABANDON, msgid );
|
||||
} else {
|
||||
#endif /* CLDAP */
|
||||
bererr = ber_printf( ber, "{iti",
|
||||
++ld->ld_msgid, LDAP_REQ_ABANDON, msgid );
|
||||
#ifdef CLDAP
|
||||
}
|
||||
#endif /* CLDAP */
|
||||
LDAP_MUTEX_UNLOCK( ld, LDAP_MSGID_LOCK );
|
||||
|
||||
if ( bererr == -1 ||
|
||||
( lderr = nsldapi_put_controls( ld, serverctrls,
|
||||
1, ber )) != LDAP_SUCCESS ) {
|
||||
lderr = LDAP_ENCODING_ERROR;
|
||||
ber_free( ber, 1 );
|
||||
} else {
|
||||
/* send the message */
|
||||
if ( lr != NULL ) {
|
||||
sb = lr->lr_conn->lconn_sb;
|
||||
} else {
|
||||
sb = ld->ld_sbp;
|
||||
}
|
||||
if ( nsldapi_ber_flush( ld, sb, ber, 1, 0 )
|
||||
!= 0 ) {
|
||||
lderr = LDAP_SERVER_DOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( lr != NULL ) {
|
||||
if ( sendabandon ) {
|
||||
nsldapi_free_connection( ld, lr->lr_conn, 0, 1 );
|
||||
}
|
||||
if ( origid == msgid ) {
|
||||
nsldapi_free_request( ld, lr, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LDAP_MUTEX_LOCK( ld, LDAP_ABANDON_LOCK );
|
||||
if ( ld->ld_abandoned == NULL ) {
|
||||
if ( (ld->ld_abandoned = (int *)NSLDAPI_MALLOC( 2
|
||||
* sizeof(int) )) == NULL ) {
|
||||
lderr = LDAP_NO_MEMORY;
|
||||
LDAP_MUTEX_UNLOCK( ld, LDAP_ABANDON_LOCK );
|
||||
goto set_errorcode_and_return;
|
||||
}
|
||||
i = 0;
|
||||
} else {
|
||||
for ( i = 0; ld->ld_abandoned[i] != -1; i++ )
|
||||
; /* NULL */
|
||||
if ( (ld->ld_abandoned = (int *)NSLDAPI_REALLOC( (char *)
|
||||
ld->ld_abandoned, (i + 2) * sizeof(int) )) == NULL ) {
|
||||
lderr = LDAP_NO_MEMORY;
|
||||
LDAP_MUTEX_UNLOCK( ld, LDAP_ABANDON_LOCK );
|
||||
goto set_errorcode_and_return;
|
||||
}
|
||||
}
|
||||
ld->ld_abandoned[i] = msgid;
|
||||
ld->ld_abandoned[i + 1] = -1;
|
||||
LDAP_MUTEX_UNLOCK( ld, LDAP_ABANDON_LOCK );
|
||||
|
||||
set_errorcode_and_return:
|
||||
LDAP_SET_LDERRNO( ld, lderr, NULL, NULL );
|
||||
return( lderr );
|
||||
}
|
||||
201
mozilla/directory/c-sdk/ldap/libraries/libldap/add.c
Normal file
@@ -0,0 +1,201 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1990 Regents of the University of Michigan.
|
||||
* All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* add.c
|
||||
*/
|
||||
|
||||
#if 0
|
||||
#ifndef lint
|
||||
static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "ldap-int.h"
|
||||
|
||||
/*
|
||||
* ldap_add - initiate an ldap (and X.500) add operation. Parameters:
|
||||
*
|
||||
* ld LDAP descriptor
|
||||
* dn DN of the entry to add
|
||||
* mods List of attributes for the entry. This is a null-
|
||||
* terminated array of pointers to LDAPMod structures.
|
||||
* only the type and values in the structures need be
|
||||
* filled in.
|
||||
*
|
||||
* Example:
|
||||
* LDAPMod *attrs[] = {
|
||||
* { 0, "cn", { "babs jensen", "babs", 0 } },
|
||||
* { 0, "sn", { "jensen", 0 } },
|
||||
* { 0, "objectClass", { "person", 0 } },
|
||||
* 0
|
||||
* }
|
||||
* msgid = ldap_add( ld, dn, attrs );
|
||||
*/
|
||||
int
|
||||
LDAP_CALL
|
||||
ldap_add( LDAP *ld, const char *dn, LDAPMod **attrs )
|
||||
{
|
||||
int msgid;
|
||||
|
||||
LDAPDebug( LDAP_DEBUG_TRACE, "ldap_add\n", 0, 0, 0 );
|
||||
|
||||
if ( ldap_add_ext( ld, dn, attrs, NULL, NULL, &msgid )
|
||||
== LDAP_SUCCESS ) {
|
||||
return( msgid );
|
||||
} else {
|
||||
return( -1 ); /* error is in ld handle */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* LDAPv3 extended add.
|
||||
* Returns an LDAP error code.
|
||||
*/
|
||||
int
|
||||
LDAP_CALL
|
||||
ldap_add_ext( LDAP *ld, const char *dn, LDAPMod **attrs,
|
||||
LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp )
|
||||
{
|
||||
BerElement *ber;
|
||||
int i, rc, lderr;
|
||||
|
||||
/*
|
||||
* An add request looks like this:
|
||||
* AddRequest ::= SEQUENCE {
|
||||
* entry DistinguishedName,
|
||||
* attrs SEQUENCE OF SEQUENCE {
|
||||
* type AttributeType,
|
||||
* values SET OF AttributeValue
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
|
||||
LDAPDebug( LDAP_DEBUG_TRACE, "ldap_add_ext\n", 0, 0, 0 );
|
||||
|
||||
if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) {
|
||||
return( LDAP_PARAM_ERROR );
|
||||
}
|
||||
|
||||
if ( !NSLDAPI_VALID_NONEMPTY_LDAPMOD_ARRAY( attrs )
|
||||
|| msgidp == NULL ) {
|
||||
lderr = LDAP_PARAM_ERROR;
|
||||
LDAP_SET_LDERRNO( ld, lderr, NULL, NULL );
|
||||
return( lderr );
|
||||
}
|
||||
|
||||
if ( dn == NULL ) {
|
||||
dn = "";
|
||||
}
|
||||
|
||||
LDAP_MUTEX_LOCK( ld, LDAP_MSGID_LOCK );
|
||||
*msgidp = ++ld->ld_msgid;
|
||||
LDAP_MUTEX_UNLOCK( ld, LDAP_MSGID_LOCK );
|
||||
|
||||
/* see if we should add to the cache */
|
||||
if ( ld->ld_cache_on && ld->ld_cache_add != NULL ) {
|
||||
LDAP_MUTEX_LOCK( ld, LDAP_CACHE_LOCK );
|
||||
if ( (rc = (ld->ld_cache_add)( ld, *msgidp, LDAP_REQ_ADD, dn,
|
||||
attrs )) != 0 ) {
|
||||
*msgidp = rc;
|
||||
LDAP_MUTEX_UNLOCK( ld, LDAP_CACHE_LOCK );
|
||||
return( LDAP_SUCCESS );
|
||||
}
|
||||
LDAP_MUTEX_UNLOCK( ld, LDAP_CACHE_LOCK );
|
||||
}
|
||||
|
||||
/* create a message to send */
|
||||
if (( lderr = nsldapi_alloc_ber_with_options( ld, &ber ))
|
||||
!= LDAP_SUCCESS ) {
|
||||
return( lderr );
|
||||
}
|
||||
|
||||
if ( ber_printf( ber, "{it{s{", *msgidp, LDAP_REQ_ADD, dn )
|
||||
== -1 ) {
|
||||
lderr = LDAP_ENCODING_ERROR;
|
||||
LDAP_SET_LDERRNO( ld, lderr, NULL, NULL );
|
||||
ber_free( ber, 1 );
|
||||
return( lderr );
|
||||
}
|
||||
|
||||
/* for each attribute in the entry... */
|
||||
for ( i = 0; attrs[i] != NULL; i++ ) {
|
||||
if ( ( attrs[i]->mod_op & LDAP_MOD_BVALUES) != 0 ) {
|
||||
rc = ber_printf( ber, "{s[V]}", attrs[i]->mod_type,
|
||||
attrs[i]->mod_bvalues );
|
||||
} else {
|
||||
rc = ber_printf( ber, "{s[v]}", attrs[i]->mod_type,
|
||||
attrs[i]->mod_values );
|
||||
}
|
||||
if ( rc == -1 ) {
|
||||
lderr = LDAP_ENCODING_ERROR;
|
||||
LDAP_SET_LDERRNO( ld, lderr, NULL, NULL );
|
||||
ber_free( ber, 1 );
|
||||
return( lderr );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ber_printf( ber, "}}" ) == -1 ) {
|
||||
lderr = LDAP_ENCODING_ERROR;
|
||||
LDAP_SET_LDERRNO( ld, lderr, NULL, NULL );
|
||||
ber_free( ber, 1 );
|
||||
return( lderr );
|
||||
}
|
||||
|
||||
if (( lderr = nsldapi_put_controls( ld, serverctrls, 1, ber ))
|
||||
!= LDAP_SUCCESS ) {
|
||||
ber_free( ber, 1 );
|
||||
return( lderr );
|
||||
}
|
||||
|
||||
/* send the message */
|
||||
rc = nsldapi_send_initial_request( ld, *msgidp, LDAP_REQ_ADD,
|
||||
(char *) dn, ber );
|
||||
*msgidp = rc;
|
||||
return( rc < 0 ? LDAP_GET_LDERRNO( ld, NULL, NULL ) : LDAP_SUCCESS );
|
||||
}
|
||||
|
||||
int
|
||||
LDAP_CALL
|
||||
ldap_add_s( LDAP *ld, const char *dn, LDAPMod **attrs )
|
||||
{
|
||||
return( ldap_add_ext_s( ld, dn, attrs, NULL, NULL ));
|
||||
}
|
||||
|
||||
int LDAP_CALL
|
||||
ldap_add_ext_s( LDAP *ld, const char *dn, LDAPMod **attrs,
|
||||
LDAPControl **serverctrls, LDAPControl **clientctrls )
|
||||
{
|
||||
int err, msgid;
|
||||
LDAPMessage *res;
|
||||
|
||||
if (( err = ldap_add_ext( ld, dn, attrs, serverctrls, clientctrls,
|
||||
&msgid )) != LDAP_SUCCESS ) {
|
||||
return( err );
|
||||
}
|
||||
|
||||
if ( ldap_result( ld, msgid, 1, (struct timeval *)NULL, &res ) == -1 ) {
|
||||
return( LDAP_GET_LDERRNO( ld, NULL, NULL ) );
|
||||
}
|
||||
|
||||
return( ldap_result2error( ld, res, 1 ) );
|
||||
}
|
||||
155
mozilla/directory/c-sdk/ldap/libraries/libldap/bind.c
Normal file
@@ -0,0 +1,155 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1990 Regents of the University of Michigan.
|
||||
* All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* bind.c
|
||||
*/
|
||||
|
||||
#if 0
|
||||
#ifndef lint
|
||||
static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "ldap-int.h"
|
||||
|
||||
/*
|
||||
* ldap_bind - bind to the ldap server (and X.500). The dn and password
|
||||
* of the entry to which to bind are supplied, along with the authentication
|
||||
* method to use. The msgid of the bind request is returned on success,
|
||||
* -1 if there's trouble. Note, the kerberos support assumes the user already
|
||||
* has a valid tgt for now. ldap_result() should be called to find out the
|
||||
* outcome of the bind request.
|
||||
*
|
||||
* Example:
|
||||
* ldap_bind( ld, "cn=manager, o=university of michigan, c=us", "secret",
|
||||
* LDAP_AUTH_SIMPLE )
|
||||
*/
|
||||
|
||||
int
|
||||
LDAP_CALL
|
||||
ldap_bind( LDAP *ld, const char *dn, const char *passwd, int authmethod )
|
||||
{
|
||||
/*
|
||||
* The bind request looks like this:
|
||||
* BindRequest ::= SEQUENCE {
|
||||
* version INTEGER,
|
||||
* name DistinguishedName, -- who
|
||||
* authentication CHOICE {
|
||||
* simple [0] OCTET STRING -- passwd
|
||||
* }
|
||||
* }
|
||||
* all wrapped up in an LDAPMessage sequence.
|
||||
*/
|
||||
|
||||
LDAPDebug( LDAP_DEBUG_TRACE, "ldap_bind\n", 0, 0, 0 );
|
||||
|
||||
if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) {
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
switch ( authmethod ) {
|
||||
case LDAP_AUTH_SIMPLE:
|
||||
return( ldap_simple_bind( ld, dn, passwd ) );
|
||||
|
||||
default:
|
||||
LDAP_SET_LDERRNO( ld, LDAP_AUTH_UNKNOWN, NULL, NULL );
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ldap_bind_s - bind to the ldap server (and X.500). The dn and password
|
||||
* of the entry to which to bind are supplied, along with the authentication
|
||||
* method to use. This routine just calls whichever bind routine is
|
||||
* appropriate and returns the result of the bind (e.g. LDAP_SUCCESS or
|
||||
* some other error indication). Note, the kerberos support assumes the
|
||||
* user already has a valid tgt for now.
|
||||
*
|
||||
* Examples:
|
||||
* ldap_bind_s( ld, "cn=manager, o=university of michigan, c=us",
|
||||
* "secret", LDAP_AUTH_SIMPLE )
|
||||
* ldap_bind_s( ld, "cn=manager, o=university of michigan, c=us",
|
||||
* NULL, LDAP_AUTH_KRBV4 )
|
||||
*/
|
||||
int
|
||||
LDAP_CALL
|
||||
ldap_bind_s( LDAP *ld, const char *dn, const char *passwd, int authmethod )
|
||||
{
|
||||
int err;
|
||||
|
||||
LDAPDebug( LDAP_DEBUG_TRACE, "ldap_bind_s\n", 0, 0, 0 );
|
||||
|
||||
switch ( authmethod ) {
|
||||
case LDAP_AUTH_SIMPLE:
|
||||
return( ldap_simple_bind_s( ld, dn, passwd ) );
|
||||
|
||||
default:
|
||||
err = LDAP_AUTH_UNKNOWN;
|
||||
LDAP_SET_LDERRNO( ld, err, NULL, NULL );
|
||||
return( err );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LDAP_CALL
|
||||
ldap_set_rebind_proc( LDAP *ld, LDAP_REBINDPROC_CALLBACK *rebindproc,
|
||||
void *arg )
|
||||
{
|
||||
if ( ld == NULL ) {
|
||||
if ( !nsldapi_initialized ) {
|
||||
nsldapi_initialize_defaults();
|
||||
}
|
||||
ld = &nsldapi_ld_defaults;
|
||||
}
|
||||
|
||||
if ( NSLDAPI_VALID_LDAP_POINTER( ld )) {
|
||||
LDAP_MUTEX_LOCK( ld, LDAP_OPTION_LOCK );
|
||||
ld->ld_rebind_fn = rebindproc;
|
||||
ld->ld_rebind_arg = arg;
|
||||
LDAP_MUTEX_UNLOCK( ld, LDAP_OPTION_LOCK );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* return a pointer to the bind DN for the default connection (a copy is
|
||||
* not made). If there is no bind DN available, NULL is returned.
|
||||
*/
|
||||
char *
|
||||
nsldapi_get_binddn( LDAP *ld )
|
||||
{
|
||||
char *binddn;
|
||||
|
||||
binddn = NULL; /* default -- assume they are not bound */
|
||||
|
||||
LDAP_MUTEX_LOCK( ld, LDAP_CONN_LOCK );
|
||||
if ( NULL != ld->ld_defconn && LDAP_CONNST_CONNECTED ==
|
||||
ld->ld_defconn->lconn_status && ld->ld_defconn->lconn_bound ) {
|
||||
if (( binddn = ld->ld_defconn->lconn_binddn ) == NULL ) {
|
||||
binddn = "";
|
||||
}
|
||||
}
|
||||
LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK );
|
||||
|
||||
return( binddn );
|
||||
}
|
||||
126
mozilla/directory/c-sdk/ldap/libraries/libldap/cache.c
Normal file
@@ -0,0 +1,126 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1993 The Regents of the University of Michigan.
|
||||
* All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* cache.c - generic caching support for LDAP
|
||||
*/
|
||||
|
||||
#include "ldap-int.h"
|
||||
|
||||
/*
|
||||
* ldap_cache_flush - flush part of the LDAP cache. returns an
|
||||
* ldap error code (LDAP_SUCCESS, LDAP_NO_SUCH_OBJECT, etc.).
|
||||
*/
|
||||
|
||||
int
|
||||
LDAP_CALL
|
||||
ldap_cache_flush( LDAP *ld, const char *dn, const char *filter )
|
||||
{
|
||||
if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) {
|
||||
return( LDAP_PARAM_ERROR );
|
||||
}
|
||||
|
||||
if ( dn == NULL ) {
|
||||
dn = "";
|
||||
}
|
||||
|
||||
return( (ld->ld_cache_flush)( ld, dn, filter ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* nsldapi_add_result_to_cache - add an ldap entry we just read off the network
|
||||
* to the ldap cache. this routine parses the ber for the entry and
|
||||
* constructs the appropriate add request. this routine calls the
|
||||
* cache add routine to actually add the entry.
|
||||
*/
|
||||
|
||||
void
|
||||
nsldapi_add_result_to_cache( LDAP *ld, LDAPMessage *m )
|
||||
{
|
||||
char *dn;
|
||||
LDAPMod **mods;
|
||||
int i, max, rc;
|
||||
char *a;
|
||||
BerElement *ber;
|
||||
char buf[50];
|
||||
struct berval bv;
|
||||
struct berval *bvp[2];
|
||||
|
||||
LDAPDebug( LDAP_DEBUG_TRACE, "=> nsldapi_add_result_to_cache id %d type %d\n",
|
||||
m->lm_msgid, m->lm_msgtype, 0 );
|
||||
if ( m->lm_msgtype != LDAP_RES_SEARCH_ENTRY ||
|
||||
ld->ld_cache_add == NULL ) {
|
||||
LDAPDebug( LDAP_DEBUG_TRACE,
|
||||
"<= nsldapi_add_result_to_cache not added\n", 0, 0, 0 );
|
||||
return;
|
||||
}
|
||||
|
||||
#define GRABSIZE 5
|
||||
|
||||
dn = ldap_get_dn( ld, m );
|
||||
mods = (LDAPMod **)NSLDAPI_MALLOC( GRABSIZE * sizeof(LDAPMod *) );
|
||||
max = GRABSIZE;
|
||||
for ( i = 0, a = ldap_first_attribute( ld, m, &ber ); a != NULL;
|
||||
a = ldap_next_attribute( ld, m, ber ), i++ ) {
|
||||
if ( i == (max - 1) ) {
|
||||
max += GRABSIZE;
|
||||
mods = (LDAPMod **)NSLDAPI_REALLOC( mods,
|
||||
sizeof(LDAPMod *) * max );
|
||||
}
|
||||
|
||||
mods[i] = (LDAPMod *)NSLDAPI_CALLOC( 1, sizeof(LDAPMod) );
|
||||
mods[i]->mod_op = LDAP_MOD_BVALUES;
|
||||
mods[i]->mod_type = a;
|
||||
mods[i]->mod_bvalues = ldap_get_values_len( ld, m, a );
|
||||
}
|
||||
if ( ber != NULL ) {
|
||||
ber_free( ber, 0 );
|
||||
}
|
||||
if (( rc = LDAP_GET_LDERRNO( ld, NULL, NULL )) != LDAP_SUCCESS ) {
|
||||
LDAPDebug( LDAP_DEBUG_TRACE,
|
||||
"<= nsldapi_add_result_to_cache error: failed to construct mod list (%s)\n",
|
||||
ldap_err2string( rc ), 0, 0 );
|
||||
ldap_mods_free( mods, 1 );
|
||||
return;
|
||||
}
|
||||
|
||||
/* update special cachedtime attribute */
|
||||
if ( i == (max - 1) ) {
|
||||
max++;
|
||||
mods = (LDAPMod **)NSLDAPI_REALLOC( mods,
|
||||
sizeof(LDAPMod *) * max );
|
||||
}
|
||||
mods[i] = (LDAPMod *)NSLDAPI_CALLOC( 1, sizeof(LDAPMod) );
|
||||
mods[i]->mod_op = LDAP_MOD_BVALUES;
|
||||
mods[i]->mod_type = "cachedtime";
|
||||
sprintf( buf, "%d", time( NULL ) );
|
||||
bv.bv_val = buf;
|
||||
bv.bv_len = strlen( buf );
|
||||
bvp[0] = &bv;
|
||||
bvp[1] = NULL;
|
||||
mods[i]->mod_bvalues = bvp;
|
||||
mods[++i] = NULL;
|
||||
|
||||
/* msgid of -1 means don't send the result */
|
||||
rc = (ld->ld_cache_add)( ld, -1, m->lm_msgtype, dn, mods );
|
||||
LDAPDebug( LDAP_DEBUG_TRACE,
|
||||
"<= nsldapi_add_result_to_cache added (rc %d)\n", rc, 0, 0 );
|
||||
}
|
||||
225
mozilla/directory/c-sdk/ldap/libraries/libldap/charray.c
Normal file
@@ -0,0 +1,225 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* charray.c - routines for dealing with char * arrays */
|
||||
|
||||
#include "ldap-int.h"
|
||||
|
||||
/*
|
||||
* Add s at the end of the array of strings *a.
|
||||
* Return 0 for success, -1 for failure.
|
||||
*/
|
||||
int
|
||||
LDAP_CALL
|
||||
ldap_charray_add(
|
||||
char ***a,
|
||||
char *s
|
||||
)
|
||||
{
|
||||
int n;
|
||||
|
||||
if ( *a == NULL ) {
|
||||
*a = (char **)NSLDAPI_MALLOC( 2 * sizeof(char *) );
|
||||
if ( *a == NULL ) {
|
||||
return -1;
|
||||
}
|
||||
n = 0;
|
||||
} else {
|
||||
for ( n = 0; *a != NULL && (*a)[n] != NULL; n++ ) {
|
||||
; /* NULL */
|
||||
}
|
||||
|
||||
*a = (char **)NSLDAPI_REALLOC( (char *) *a,
|
||||
(n + 2) * sizeof(char *) );
|
||||
if ( *a == NULL ) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
(*a)[n++] = s;
|
||||
(*a)[n] = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add array of strings s at the end of the array of strings *a.
|
||||
* Return 0 for success, -1 for failure.
|
||||
*/
|
||||
int
|
||||
LDAP_CALL
|
||||
ldap_charray_merge(
|
||||
char ***a,
|
||||
char **s
|
||||
)
|
||||
{
|
||||
int i, n, nn;
|
||||
|
||||
if ( (s == NULL) || (s[0] == NULL) )
|
||||
return 0;
|
||||
|
||||
for ( n = 0; *a != NULL && (*a)[n] != NULL; n++ ) {
|
||||
; /* NULL */
|
||||
}
|
||||
for ( nn = 0; s[nn] != NULL; nn++ ) {
|
||||
; /* NULL */
|
||||
}
|
||||
|
||||
*a = (char **)NSLDAPI_REALLOC( (char *) *a,
|
||||
(n + nn + 1) * sizeof(char *) );
|
||||
if ( *a == NULL ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for ( i = 0; i < nn; i++ ) {
|
||||
(*a)[n + i] = s[i];
|
||||
}
|
||||
(*a)[n + nn] = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
LDAP_CALL
|
||||
ldap_charray_free( char **array )
|
||||
{
|
||||
char **a;
|
||||
|
||||
if ( array == NULL ) {
|
||||
return;
|
||||
}
|
||||
|
||||
for ( a = array; *a != NULL; a++ ) {
|
||||
if ( *a != NULL ) {
|
||||
NSLDAPI_FREE( *a );
|
||||
}
|
||||
}
|
||||
NSLDAPI_FREE( (char *) array );
|
||||
}
|
||||
|
||||
int
|
||||
LDAP_CALL
|
||||
ldap_charray_inlist(
|
||||
char **a,
|
||||
char *s
|
||||
)
|
||||
{
|
||||
int i;
|
||||
|
||||
if ( a == NULL )
|
||||
return( 0 );
|
||||
|
||||
for ( i = 0; a[i] != NULL; i++ ) {
|
||||
if ( strcasecmp( s, a[i] ) == 0 ) {
|
||||
return( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
* Duplicate the array of strings a, return NULL upon any memory failure.
|
||||
*/
|
||||
char **
|
||||
LDAP_CALL
|
||||
ldap_charray_dup( char **a )
|
||||
{
|
||||
int i;
|
||||
char **new;
|
||||
|
||||
for ( i = 0; a[i] != NULL; i++ )
|
||||
; /* NULL */
|
||||
|
||||
new = (char **)NSLDAPI_MALLOC( (i + 1) * sizeof(char *) );
|
||||
if ( new == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for ( i = 0; a[i] != NULL; i++ ) {
|
||||
new[i] = nsldapi_strdup( a[i] );
|
||||
if ( new[i] == NULL ) {
|
||||
int j;
|
||||
|
||||
for ( j = 0; j < i; j++ )
|
||||
NSLDAPI_FREE( new[j] );
|
||||
NSLDAPI_FREE( new );
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
new[i] = NULL;
|
||||
|
||||
return( new );
|
||||
}
|
||||
|
||||
/*
|
||||
* Tokenize the string str, return NULL upon any memory failure.
|
||||
* XXX: on many platforms this function is not thread safe because it
|
||||
* uses strtok().
|
||||
*/
|
||||
char **
|
||||
LDAP_CALL
|
||||
ldap_str2charray( char *str, char *brkstr )
|
||||
/* This implementation fails if brkstr contains multibyte characters.
|
||||
But it works OK if str is UTF-8 and brkstr is 7-bit ASCII.
|
||||
*/
|
||||
{
|
||||
char **res;
|
||||
char *s;
|
||||
int i;
|
||||
|
||||
i = 1;
|
||||
for ( s = str; *s; s++ ) {
|
||||
if ( strchr( brkstr, *s ) != NULL ) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
res = (char **)NSLDAPI_MALLOC( (i + 1) * sizeof(char *) );
|
||||
if ( res == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
i = 0;
|
||||
for ( s = strtok( str, brkstr ); s != NULL; s = strtok( NULL,
|
||||
brkstr ) ) {
|
||||
res[i++] = nsldapi_strdup( s );
|
||||
if ( res[i - 1] == NULL ) {
|
||||
int j;
|
||||
|
||||
for ( j = 0; j < (i - 1); j++ )
|
||||
NSLDAPI_FREE( res[j] );
|
||||
NSLDAPI_FREE( res );
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
res[i] = NULL;
|
||||
|
||||
return( res );
|
||||
}
|
||||
|
||||
int
|
||||
LDAP_CALL
|
||||
ldap_charray_position( char **a, char *s )
|
||||
{
|
||||
int i;
|
||||
|
||||
for ( i = 0; a[i] != NULL; i++ ) {
|
||||
if ( strcasecmp( s, a[i] ) == 0 ) {
|
||||
return( i );
|
||||
}
|
||||
}
|
||||
|
||||
return( -1 );
|
||||
}
|
||||
1826
mozilla/directory/c-sdk/ldap/libraries/libldap/charset.c
Normal file
564
mozilla/directory/c-sdk/ldap/libraries/libldap/cldap.c
Normal file
@@ -0,0 +1,564 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1990, 1994 Regents of the University of Michigan.
|
||||
* All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* cldap.c - synchronous, retrying interface to the cldap protocol
|
||||
*/
|
||||
|
||||
|
||||
#ifdef CLDAP
|
||||
|
||||
XXX not MT-safe XXX
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] = "@(#) Copyright (c) 1990, 1994 Regents of the University of Michigan.\nAll rights reserved.\n";
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#ifdef macintosh
|
||||
#include <stdlib.h>
|
||||
#include "macos.h"
|
||||
#else /* macintosh */
|
||||
#ifdef DOS
|
||||
#include "msdos.h"
|
||||
#else /* DOS */
|
||||
#ifdef _WINDOWS
|
||||
#include <windows.h>
|
||||
#else /* _WINDOWS */
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#endif /* _WINDOWS */
|
||||
#endif /* DOS */
|
||||
#endif /* macintosh */
|
||||
|
||||
#include "ldap-int.h"
|
||||
|
||||
#define DEF_CLDAP_TIMEOUT 3
|
||||
#define DEF_CLDAP_TRIES 4
|
||||
|
||||
#ifndef INADDR_LOOPBACK
|
||||
#define INADDR_LOOPBACK ((unsigned long) 0x7f000001)
|
||||
#endif
|
||||
|
||||
|
||||
struct cldap_retinfo {
|
||||
int cri_maxtries;
|
||||
int cri_try;
|
||||
int cri_useaddr;
|
||||
long cri_timeout;
|
||||
};
|
||||
|
||||
#ifdef NEEDPROTOS
|
||||
static int add_addr( LDAP *ld, struct sockaddr *sap );
|
||||
static int cldap_result( LDAP *ld, int msgid, LDAPMessage **res,
|
||||
struct cldap_retinfo *crip, char *base );
|
||||
static int cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
|
||||
LDAPMessage **res, char *base );
|
||||
#else /* NEEDPROTOS */
|
||||
static int add_addr();
|
||||
static int cldap_result();
|
||||
static int cldap_parsemsg();
|
||||
#endif /* NEEDPROTOS */
|
||||
|
||||
/*
|
||||
* cldap_open - initialize and connect to an ldap server. A magic cookie to
|
||||
* be used for future communication is returned on success, NULL on failure.
|
||||
*
|
||||
* Example:
|
||||
* LDAP *ld;
|
||||
* ld = cldap_open( hostname, port );
|
||||
*/
|
||||
|
||||
LDAP *
|
||||
cldap_open( char *host, int port )
|
||||
{
|
||||
int s;
|
||||
unsigned long address;
|
||||
struct sockaddr_in sock;
|
||||
struct hostent *hp;
|
||||
LDAP *ld;
|
||||
char *p;
|
||||
int i;
|
||||
|
||||
LDAPDebug( LDAP_DEBUG_TRACE, "cldap_open\n", 0, 0, 0 );
|
||||
|
||||
if ( port == 0 ) {
|
||||
port = LDAP_PORT;
|
||||
}
|
||||
|
||||
if ( (s = socket( AF_INET, SOCK_DGRAM, 0 )) < 0 ) {
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
sock.sin_addr.s_addr = 0;
|
||||
sock.sin_family = AF_INET;
|
||||
sock.sin_port = 0;
|
||||
if ( bind(s, (struct sockaddr *) &sock, sizeof(sock)) < 0) {
|
||||
close( s );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
if (( ld = ldap_init( host, port )) == NULL ) {
|
||||
close( s );
|
||||
return( NULL );
|
||||
}
|
||||
if ( (ld->ld_sbp->sb_fromaddr = (void *)NSLDAPI_CALLOC( 1,
|
||||
sizeof( struct sockaddr ))) == NULL ) {
|
||||
NSLDAPI_FREE( ld );
|
||||
close( s );
|
||||
return( NULL );
|
||||
}
|
||||
ld->ld_sbp->sb_sd = s;
|
||||
ld->ld_sbp->sb_naddr = 0;
|
||||
ld->ld_version = LDAP_VERSION;
|
||||
|
||||
sock.sin_family = AF_INET;
|
||||
sock.sin_port = htons( port );
|
||||
|
||||
/*
|
||||
* 'host' may be a space-separated list.
|
||||
*/
|
||||
if ( host != NULL ) {
|
||||
for ( ; host != NULL; host = p ) {
|
||||
if (( p = strchr( host, ' ' )) != NULL ) {
|
||||
for (*p++ = '\0'; *p == ' '; p++) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if ( (address = inet_addr( host )) == -1 ) {
|
||||
/* XXXmcs: need to use DNS callbacks here XXX */
|
||||
XXX
|
||||
if ( (hp = gethostbyname( host )) == NULL ) {
|
||||
LDAP_SET_ERRNO( ld, EHOSTUNREACH );
|
||||
continue;
|
||||
}
|
||||
|
||||
for ( i = 0; hp->h_addr_list[ i ] != 0; ++i ) {
|
||||
SAFEMEMCPY( (char *)&sock.sin_addr.s_addr,
|
||||
(char *)hp->h_addr_list[ i ],
|
||||
sizeof(sock.sin_addr.s_addr));
|
||||
if ( add_addr( ld, (struct sockaddr *)&sock ) < 0 ) {
|
||||
close( s );
|
||||
NSLDAPI_FREE( ld );
|
||||
return( NULL );
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
sock.sin_addr.s_addr = address;
|
||||
if ( add_addr( ld, (struct sockaddr *)&sock ) < 0 ) {
|
||||
close( s );
|
||||
NSLDAPI_FREE( ld );
|
||||
return( NULL );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ld->ld_host == NULL ) {
|
||||
ld->ld_host = nsldapi_strdup( host );
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
address = INADDR_LOOPBACK;
|
||||
sock.sin_addr.s_addr = htonl( address );
|
||||
if ( add_addr( ld, (struct sockaddr *)&sock ) < 0 ) {
|
||||
close( s );
|
||||
NSLDAPI_FREE( ld );
|
||||
return( NULL );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ld->ld_sbp->sb_addrs == NULL
|
||||
|| ( ld->ld_defconn = nsldapi_new_connection( ld, NULL, 1,0,0 )) == NULL ) {
|
||||
NSLDAPI_FREE( ld );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
ld->ld_sbp->sb_useaddr = ld->ld_sbp->sb_addrs[ 0 ];
|
||||
cldap_setretryinfo( ld, 0, 0 );
|
||||
|
||||
#ifdef LDAP_DEBUG
|
||||
putchar( '\n' );
|
||||
for ( i = 0; i < ld->ld_sbp->sb_naddr; ++i ) {
|
||||
LDAPDebug( LDAP_DEBUG_TRACE, "end of cldap_open address %d is %s\n",
|
||||
i, inet_ntoa( ((struct sockaddr_in *)
|
||||
ld->ld_sbp->sb_addrs[ i ])->sin_addr ), 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
return( ld );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
cldap_close( LDAP *ld )
|
||||
{
|
||||
ldap_ld_free( ld, 0 );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
cldap_setretryinfo( LDAP *ld, int tries, int timeout )
|
||||
{
|
||||
ld->ld_cldaptries = ( tries <= 0 ) ? DEF_CLDAP_TRIES : tries;
|
||||
ld->ld_cldaptimeout = ( timeout <= 0 ) ? DEF_CLDAP_TIMEOUT : timeout;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
cldap_search_s( LDAP *ld, char *base, int scope, char *filter, char **attrs,
|
||||
int attrsonly, LDAPMessage **res, char *logdn )
|
||||
{
|
||||
int ret, msgid;
|
||||
struct cldap_retinfo cri;
|
||||
|
||||
*res = NULLMSG;
|
||||
|
||||
(void) memset( &cri, 0, sizeof( cri ));
|
||||
|
||||
if ( logdn != NULL ) {
|
||||
ld->ld_cldapdn = logdn;
|
||||
} else if ( ld->ld_cldapdn == NULL ) {
|
||||
ld->ld_cldapdn = "";
|
||||
}
|
||||
|
||||
do {
|
||||
if ( cri.cri_try != 0 ) {
|
||||
--ld->ld_msgid; /* use same id as before */
|
||||
}
|
||||
ld->ld_sbp->sb_useaddr = ld->ld_sbp->sb_addrs[ cri.cri_useaddr ];
|
||||
|
||||
LDAPDebug( LDAP_DEBUG_TRACE, "cldap_search_s try %d (to %s)\n",
|
||||
cri.cri_try, inet_ntoa( ((struct sockaddr_in *)
|
||||
ld->ld_sbp->sb_useaddr)->sin_addr ), 0 );
|
||||
|
||||
if ( (msgid = ldap_search( ld, base, scope, filter, attrs,
|
||||
attrsonly )) == -1 ) {
|
||||
return( LDAP_GET_LDERRNO( ld, NULL, NULL ) );
|
||||
}
|
||||
#ifndef NO_CACHE
|
||||
if ( ld->ld_cache != NULL && ld->ld_responses != NULL ) {
|
||||
LDAPDebug( LDAP_DEBUG_TRACE, "cldap_search_s res from cache\n",
|
||||
0, 0, 0 );
|
||||
*res = ld->ld_responses;
|
||||
ld->ld_responses = ld->ld_responses->lm_next;
|
||||
return( ldap_result2error( ld, *res, 0 ));
|
||||
}
|
||||
#endif /* NO_CACHE */
|
||||
ret = cldap_result( ld, msgid, res, &cri, base );
|
||||
} while (ret == -1);
|
||||
|
||||
return( ret );
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
add_addr( LDAP *ld, struct sockaddr *sap )
|
||||
{
|
||||
struct sockaddr *newsap, **addrs;
|
||||
|
||||
if (( newsap = (struct sockaddr *)NSLDAPI_MALLOC(
|
||||
sizeof( struct sockaddr ))) == NULL ) {
|
||||
LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
if ( ld->ld_sbp->sb_naddr == 0 ) {
|
||||
addrs = (struct sockaddr **)NSLDAPI_MALLOC( sizeof(struct sockaddr *));
|
||||
} else {
|
||||
addrs = (struct sockaddr **)NSLDAPI_REALLOC( ld->ld_sbp->sb_addrs,
|
||||
( ld->ld_sbp->sb_naddr + 1 ) * sizeof(struct sockaddr *));
|
||||
}
|
||||
|
||||
if ( addrs == NULL ) {
|
||||
NSLDAPI_FREE( newsap );
|
||||
LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
SAFEMEMCPY( (char *)newsap, (char *)sap, sizeof( struct sockaddr ));
|
||||
addrs[ ld->ld_sbp->sb_naddr++ ] = newsap;
|
||||
ld->ld_sbp->sb_addrs = (void **)addrs;
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
cldap_result( LDAP *ld, int msgid, LDAPMessage **res,
|
||||
struct cldap_retinfo *crip, char *base )
|
||||
{
|
||||
Sockbuf *sb = ld->ld_sbp;
|
||||
BerElement ber;
|
||||
char *logdn;
|
||||
int ret, id, fromaddr, i;
|
||||
struct timeval tv;
|
||||
|
||||
fromaddr = -1;
|
||||
|
||||
if ( crip->cri_try == 0 ) {
|
||||
crip->cri_maxtries = ld->ld_cldaptries * sb->sb_naddr;
|
||||
crip->cri_timeout = ld->ld_cldaptimeout;
|
||||
crip->cri_useaddr = 0;
|
||||
LDAPDebug( LDAP_DEBUG_TRACE, "cldap_result tries %d timeout %d\n",
|
||||
ld->ld_cldaptries, ld->ld_cldaptimeout, 0 );
|
||||
}
|
||||
|
||||
if ((tv.tv_sec = crip->cri_timeout / sb->sb_naddr) < 1 ) {
|
||||
tv.tv_sec = 1;
|
||||
}
|
||||
tv.tv_usec = 0;
|
||||
|
||||
LDAPDebug( LDAP_DEBUG_TRACE,
|
||||
"cldap_result waiting up to %d seconds for a response\n",
|
||||
tv.tv_sec, 0, 0 );
|
||||
ber_init_w_nullchar( &ber, 0 );
|
||||
nsldapi_set_ber_options( ld, &ber );
|
||||
|
||||
if ( cldap_getmsg( ld, &tv, &ber ) == -1 ) {
|
||||
ret = LDAP_GET_LDERRNO( ld, NULL, NULL );
|
||||
LDAPDebug( LDAP_DEBUG_TRACE, "cldap_getmsg returned -1 (%d)\n",
|
||||
ret, 0, 0 );
|
||||
} else if ( LDAP_GET_LDERRNO( ld, NULL, NULL ) == LDAP_TIMEOUT ) {
|
||||
LDAPDebug( LDAP_DEBUG_TRACE,
|
||||
"cldap_result timed out\n", 0, 0, 0 );
|
||||
/*
|
||||
* It timed out; is it time to give up?
|
||||
*/
|
||||
if ( ++crip->cri_try >= crip->cri_maxtries ) {
|
||||
ret = LDAP_TIMEOUT;
|
||||
--crip->cri_try;
|
||||
} else {
|
||||
if ( ++crip->cri_useaddr >= sb->sb_naddr ) {
|
||||
/*
|
||||
* new round: reset address to first one and
|
||||
* double the timeout
|
||||
*/
|
||||
crip->cri_useaddr = 0;
|
||||
crip->cri_timeout <<= 1;
|
||||
}
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
} else {
|
||||
/*
|
||||
* Got a response. It should look like:
|
||||
* { msgid, logdn, { searchresponse...}}
|
||||
*/
|
||||
logdn = NULL;
|
||||
|
||||
if ( ber_scanf( &ber, "ia", &id, &logdn ) == LBER_ERROR ) {
|
||||
NSLDAPI_FREE( ber.ber_buf ); /* gack! */
|
||||
ret = LDAP_DECODING_ERROR;
|
||||
LDAPDebug( LDAP_DEBUG_TRACE,
|
||||
"cldap_result: ber_scanf returned LBER_ERROR (%d)\n",
|
||||
ret, 0, 0 );
|
||||
} else if ( id != msgid ) {
|
||||
NSLDAPI_FREE( ber.ber_buf ); /* gack! */
|
||||
LDAPDebug( LDAP_DEBUG_TRACE,
|
||||
"cldap_result: looking for msgid %d; got %d\n",
|
||||
msgid, id, 0 );
|
||||
ret = -1; /* ignore and keep looking */
|
||||
} else {
|
||||
/*
|
||||
* got a result: determine which server it came from
|
||||
* decode into ldap message chain
|
||||
*/
|
||||
for ( fromaddr = 0; fromaddr < sb->sb_naddr; ++fromaddr ) {
|
||||
if ( memcmp( &((struct sockaddr_in *)
|
||||
sb->sb_addrs[ fromaddr ])->sin_addr,
|
||||
&((struct sockaddr_in *)sb->sb_fromaddr)->sin_addr,
|
||||
sizeof( struct in_addr )) == 0 ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
ret = cldap_parsemsg( ld, msgid, &ber, res, base );
|
||||
NSLDAPI_FREE( ber.ber_buf ); /* gack! */
|
||||
LDAPDebug( LDAP_DEBUG_TRACE,
|
||||
"cldap_result got result (%d)\n", ret, 0, 0 );
|
||||
}
|
||||
|
||||
if ( logdn != NULL ) {
|
||||
NSLDAPI_FREE( logdn );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* If we are giving up (successfully or otherwise) then
|
||||
* abandon any outstanding requests.
|
||||
*/
|
||||
if ( ret != -1 ) {
|
||||
i = crip->cri_try;
|
||||
if ( i >= sb->sb_naddr ) {
|
||||
i = sb->sb_naddr - 1;
|
||||
}
|
||||
|
||||
for ( ; i >= 0; --i ) {
|
||||
if ( i == fromaddr ) {
|
||||
continue;
|
||||
}
|
||||
sb->sb_useaddr = sb->sb_addrs[ i ];
|
||||
LDAPDebug( LDAP_DEBUG_TRACE, "cldap_result abandoning id %d (to %s)\n",
|
||||
msgid, inet_ntoa( ((struct sockaddr_in *)
|
||||
sb->sb_useaddr)->sin_addr ), 0 );
|
||||
(void) ldap_abandon( ld, msgid );
|
||||
}
|
||||
}
|
||||
|
||||
LDAP_SET_LDERRNO( ld, ret, NULL, NULL );
|
||||
return( ret );
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
|
||||
LDAPMessage **res, char *base )
|
||||
{
|
||||
unsigned long tag, len;
|
||||
int baselen, slen, rc;
|
||||
char *dn, *p, *cookie;
|
||||
LDAPMessage *chain, *prev, *ldm;
|
||||
struct berval *bv;
|
||||
|
||||
rc = LDAP_DECODING_ERROR; /* pessimistic */
|
||||
ldm = chain = prev = NULLMSG;
|
||||
baselen = ( base == NULL ) ? 0 : strlen( base );
|
||||
bv = NULL;
|
||||
|
||||
for ( tag = ber_first_element( ber, &len, &cookie );
|
||||
tag != LBER_ERROR && tag != LBER_END_OF_SEQOFSET
|
||||
&& rc != LDAP_SUCCESS;
|
||||
tag = ber_next_element( ber, &len, cookie )) {
|
||||
if (( ldm = (LDAPMessage *)NSLDAPI_CALLOC( 1, sizeof(LDAPMessage)))
|
||||
== NULL ) {
|
||||
rc = LDAP_NO_MEMORY;
|
||||
break; /* return with error */
|
||||
} else if (( rc = nsldapi_alloc_ber_with_options( ld, &ldm->lm_ber ))
|
||||
!= LDAP_SUCCESS ) {
|
||||
break; /* return with error*/
|
||||
}
|
||||
ldm->lm_msgid = msgid;
|
||||
ldm->lm_msgtype = tag;
|
||||
|
||||
if ( tag == LDAP_RES_SEARCH_RESULT ) {
|
||||
LDAPDebug( LDAP_DEBUG_TRACE, "cldap_parsemsg got search result\n",
|
||||
0, 0, 0 );
|
||||
|
||||
if ( ber_get_stringal( ber, &bv ) == LBER_DEFAULT ) {
|
||||
break; /* return w/error */
|
||||
}
|
||||
|
||||
if ( ber_printf( ldm->lm_ber, "to", tag, bv->bv_val,
|
||||
bv->bv_len ) == -1 ) {
|
||||
break; /* return w/error */
|
||||
}
|
||||
ber_bvfree( bv );
|
||||
bv = NULL;
|
||||
rc = LDAP_SUCCESS;
|
||||
|
||||
} else if ( tag == LDAP_RES_SEARCH_ENTRY ) {
|
||||
if ( ber_scanf( ber, "{aO", &dn, &bv ) == LBER_ERROR ) {
|
||||
break; /* return w/error */
|
||||
}
|
||||
LDAPDebug( LDAP_DEBUG_TRACE, "cldap_parsemsg entry %s\n", dn, 0, 0 );
|
||||
if ( dn != NULL && *(dn + ( slen = strlen(dn)) - 1) == '*' &&
|
||||
baselen > 0 ) {
|
||||
/*
|
||||
* substitute original searchbase for trailing '*'
|
||||
*/
|
||||
if (( p = (char *)NSLDAPI_MALLOC( slen + baselen )) == NULL ) {
|
||||
rc = LDAP_NO_MEMORY;
|
||||
NSLDAPI_FREE( dn );
|
||||
break; /* return w/error */
|
||||
}
|
||||
strcpy( p, dn );
|
||||
strcpy( p + slen - 1, base );
|
||||
NSLDAPI_FREE( dn );
|
||||
dn = p;
|
||||
}
|
||||
|
||||
if ( ber_printf( ldm->lm_ber, "t{so}", tag, dn, bv->bv_val,
|
||||
bv->bv_len ) == -1 ) {
|
||||
break; /* return w/error */
|
||||
}
|
||||
NSLDAPI_FREE( dn );
|
||||
ber_bvfree( bv );
|
||||
bv = NULL;
|
||||
|
||||
} else {
|
||||
LDAPDebug( LDAP_DEBUG_TRACE, "cldap_parsemsg got unknown tag %d\n",
|
||||
tag, 0, 0 );
|
||||
rc = LDAP_PROTOCOL_ERROR;
|
||||
break; /* return w/error */
|
||||
}
|
||||
|
||||
/* Reset message ber so we can read from it later. Gack! */
|
||||
ldm->lm_ber->ber_end = ldm->lm_ber->ber_ptr;
|
||||
ldm->lm_ber->ber_ptr = ldm->lm_ber->ber_buf;
|
||||
|
||||
#ifdef LDAP_DEBUG
|
||||
if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
|
||||
char msg[80];
|
||||
sprintf( msg, "cldap_parsemsg add message id %d type %d:\n",
|
||||
ldm->lm_msgid, ldm->lm_msgtype );
|
||||
ber_err_print( msg );
|
||||
ber_dump( ldm->lm_ber, 1 );
|
||||
}
|
||||
#endif /* LDAP_DEBUG */
|
||||
|
||||
#ifndef NO_CACHE
|
||||
if ( ld->ld_cache != NULL ) {
|
||||
nsldapi_add_result_to_cache( ld, ldm );
|
||||
}
|
||||
#endif /* NO_CACHE */
|
||||
|
||||
if ( chain == NULL ) {
|
||||
chain = ldm;
|
||||
} else {
|
||||
prev->lm_chain = ldm;
|
||||
}
|
||||
prev = ldm;
|
||||
ldm = NULL;
|
||||
}
|
||||
|
||||
/* dispose of any leftovers */
|
||||
if ( ldm != NULL ) {
|
||||
if ( ldm->lm_ber != NULLBER ) {
|
||||
ber_free( ldm->lm_ber, 1 );
|
||||
}
|
||||
NSLDAPI_FREE( ldm );
|
||||
}
|
||||
if ( bv != NULL ) {
|
||||
ber_bvfree( bv );
|
||||
}
|
||||
|
||||
/* return chain, calling result2error if we got anything at all */
|
||||
*res = chain;
|
||||
return(( *res == NULLMSG ) ? rc : ldap_result2error( ld, *res, 0 ));
|
||||
}
|
||||
#endif /* CLDAP */
|
||||