Compare commits
12 Commits
NETSCAPE_7
...
LDAPCSDK_4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1094bbecd8 | ||
|
|
e7cc9a1ca1 | ||
|
|
155e2b78e8 | ||
|
|
26bd1be8a6 | ||
|
|
4aad72eee3 | ||
|
|
3221592283 | ||
|
|
88c5957a61 | ||
|
|
c43a7a4586 | ||
|
|
c10bcef97d | ||
|
|
e79d293e43 | ||
|
|
a67f9feefa | ||
|
|
bb8031e82c |
@@ -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,573 +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;
|
||||
|
||||
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"
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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_0_RTM
|
||||
mozilla/security/nss, NETSCAPE_7_0_RTM
|
||||
mozilla/security/manager, NETSCAPE_7_0_RTM
|
||||
mozilla/accessible, NETSCAPE_7_0_RTM
|
||||
mozilla/directory/c-sdk, NETSCAPE_7_0_RTM
|
||||
mozilla/lib/mac/Instrumentation, NETSCAPE_7_0_RTM
|
||||
mozilla/gfx2, NETSCAPE_7_0_RTM
|
||||
mozilla/modules/libpr0n, NETSCAPE_7_0_RTM
|
||||
SeaMonkeyAll, NETSCAPE_7_0_RTM
|
||||
|
||||
## 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,511 +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):
|
||||
|
||||
DEPTH=.
|
||||
|
||||
!if !defined(MOZ_TOP)
|
||||
#enable builds from changed top level directories
|
||||
MOZ_TOP=mozilla
|
||||
!endif
|
||||
|
||||
MOZ_SRC_FLIPPED = $(MOZ_SRC:\=/)
|
||||
MOZ_DIST_FLIPPED = $(MOZ_SRC_FLIPPED)/mozilla/dist
|
||||
!ifdef MOZ_DEBUG
|
||||
MOZ_OBJDIR = WIN32_D.OBJ
|
||||
!else
|
||||
MOZ_OBJDIR = WIN32_O.OBJ
|
||||
!endif
|
||||
|
||||
#
|
||||
# Command macro defines
|
||||
#
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#// Figure out how to do the pull.
|
||||
#//------------------------------------------------------------------------
|
||||
# uncomment these, modify branch tag, and check in to branch for milestones
|
||||
MOZ_BRANCH=NETSCAPE_7_0_RTM
|
||||
NSPR_CO_TAG=NETSCAPE_7_0_RTM
|
||||
PSM_CO_TAG=NETSCAPE_7_0_RTM
|
||||
NSS_CO_TAG=NETSCAPE_7_0_RTM
|
||||
LDAPCSDK_CO_TAG=NETSCAPE_7_0_RTM
|
||||
ACCESSIBLE_CO_TAG=NETSCAPE_7_0_RTM
|
||||
IMGLIB2_CO_TAG=NETSCAPE_7_0_RTM
|
||||
GFX2_CO_TAG=NETSCAPE_7_0_RTM
|
||||
|
||||
|
||||
!ifdef MOZ_BRANCH
|
||||
CVS_BRANCH=-r $(MOZ_BRANCH)
|
||||
!endif
|
||||
|
||||
!ifdef MOZ_DATE
|
||||
CVS_BRANCH=$(CVS_BRANCH) -D "$(MOZ_DATE)"
|
||||
!endif
|
||||
|
||||
# default pull is "quiet" but it can be overridden with MOZ_CVS_VERBOSE
|
||||
!ifndef MOZ_CVS_VERBOSE
|
||||
CVS_FLAGS=-q
|
||||
!endif
|
||||
|
||||
# honor any user-defined CVS flags
|
||||
!ifdef MOZ_CVS_FLAGS
|
||||
CVS_FLAGS=$(CVS_FLAGS) $(MOZ_CVS_FLAGS)
|
||||
!endif
|
||||
|
||||
# let's be explicit about CVSROOT... some windows cvs clients
|
||||
# are too stupid to correctly work without the -d option
|
||||
#
|
||||
# if they are too stupid, they should fail. I am
|
||||
# commenting this out because this does not work
|
||||
# under 4nt. (%'s are evaluted differently)
|
||||
#
|
||||
# If it breaks you, mail dougt@netscape.com
|
||||
# and leaf@mozilla.org
|
||||
#
|
||||
!if 0
|
||||
!if defined(CVSROOT)
|
||||
CVS_FLAGS=$(CVS_FLAGS) -d "$(CVSROOT)"
|
||||
!endif
|
||||
!endif
|
||||
|
||||
!ifndef MOZ_CO_FLAGS
|
||||
MOZ_CO_FLAGS = -P
|
||||
!endif
|
||||
|
||||
CVSCO = cvs $(CVS_FLAGS) co $(MOZ_CO_FLAGS) $(CVS_BRANCH)
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#// Figure out how to pull NSPR.
|
||||
#// If no NSPR_CO_TAG is specified, use the default static tag
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
!ifndef NSPR_CO_FLAGS
|
||||
NSPR_CO_FLAGS=$(MOZ_CO_FLAGS)
|
||||
!endif
|
||||
|
||||
NSPR_CO_FLAGS=$(NSPR_CO_FLAGS) $(CVS_BRANCH)
|
||||
|
||||
|
||||
CVSCO_NSPR = cvs $(CVS_FLAGS) co $(NSPR_CO_FLAGS)
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#// Figure out how to pull NSS and PSM libs.
|
||||
#// If no NSS_CO_TAG or PSM_CO_TAG is specified, use the default static tag
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
!ifndef NSS_CO_FLAGS
|
||||
NSS_CO_FLAGS=$(MOZ_CO_FLAGS)
|
||||
!endif
|
||||
|
||||
NSS_CO_FLAGS=$(NSS_CO_FLAGS) $(CVS_BRANCH)
|
||||
|
||||
CVSCO_NSS = cvs $(CVS_FLAGS) co $(NSS_CO_FLAGS)
|
||||
|
||||
!ifndef PSM_CO_FLAGS
|
||||
PSM_CO_FLAGS=$(MOZ_CO_FLAGS)
|
||||
!endif
|
||||
|
||||
PSM_CO_FLAGS=$(PSM_CO_FLAGS) $(CVS_BRANCH)
|
||||
|
||||
CVSCO_PSM = cvs $(CVS_FLAGS) co $(PSM_CO_FLAGS)
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#// Figure out how to pull LDAP C SDK client libs.
|
||||
#// If no LDAPCSDK_CO_TAG is specified, use the default tag
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
|
||||
!ifndef LDAPCSDK_CO_FLAGS
|
||||
LDAPCSDK_CO_FLAGS=$(MOZ_CO_FLAGS)
|
||||
!endif
|
||||
|
||||
LDAPCSDK_CO_FLAGS=$(LDAPCSDK_CO_FLAGS) $(CVS_BRANCH)
|
||||
|
||||
CVSCO_LDAPCSDK = cvs $(CVS_FLAGS) co $(LDAPCSDK_CO_FLAGS)
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#// Figure out how to pull accessibility libs.
|
||||
#// If no ACCESSIBLE_CO_TAG is specified, use the default tag
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
!ifndef ACCESSIBLE_CO_FLAGS
|
||||
ACCESSIBLE_CO_FLAGS=$(MOZ_CO_FLAGS)
|
||||
!endif
|
||||
|
||||
ACCESSIBLE_CO_FLAGS=$(ACCESSIBLE_CO_FLAGS) $(CVS_BRANCH)
|
||||
|
||||
CVSCO_ACCESSIBLE = cvs $(CVS_FLAGS) co $(ACCESSIBLE_CO_FLAGS)
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#// Figure out how to pull new image library.
|
||||
#// If no IMGLIB2_CO_TAG is specified, use the default tag
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
!ifndef IMGLIB2_CO_FLAGS
|
||||
IMGLIB2_CO_FLAGS=$(MOZ_CO_FLAGS)
|
||||
!endif
|
||||
|
||||
IMGLIB2_CO_FLAGS=$(IMGLIB2_CO_FLAGS) $(CVS_BRANCH)
|
||||
|
||||
CVSCO_IMGLIB2 = cvs $(CVS_FLAGS) co $(IMGLIB2_CO_FLAGS)
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#// Figure out how to pull new image library.
|
||||
#// If no GFX2_CO_TAG is specified, use the default tag
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
!ifndef GFX2_CO_FLAGS
|
||||
GFX2_CO_FLAGS=$(MOZ_CO_FLAGS)
|
||||
!endif
|
||||
|
||||
GFX2_CO_FLAGS=$(GFX2_CO_FLAGS) $(CVS_BRANCH)
|
||||
|
||||
CVSCO_GFX2 = cvs $(CVS_FLAGS) co $(GFX2_CO_FLAGS)
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#// Figure out how to pull the internal libart
|
||||
#// (only pulled and built if MOZ_INTERNAL_LIBART_LGPL is set)
|
||||
#// If no MOZ_INTERNAL_LIBART_CO_TAG is specified, use the default tag
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
!if defined(MOZ_SVG) && !defined(MOZ_INTERNAL_LIBART_LGPL)
|
||||
ERR_MESSAGE = ^
|
||||
You are trying to build Mozilla with SVG support (MOZ_SVG=1), but you ^
|
||||
haven not specified that mozilla/other-licenses/libart_lgpl should be ^
|
||||
pulled and built. At the moment Mozilla SVG builds need this patched ^
|
||||
version of libart. You either need to disable SVG support (unset MOZ_SVG) ^
|
||||
or enable pulling and building by setting MOZ_INTERNAL_LIBART_LGPL=1.^
|
||||
^
|
||||
If you choose to pull and build libart, note that it is only licensed^
|
||||
under the terms of the LGPL, not the MPL. (Which is why you have to opt^
|
||||
in explicitly.)
|
||||
!endif
|
||||
|
||||
!if defined(MOZ_INTERNAL_LIBART_LGPL)
|
||||
|
||||
!ifndef MOZ_INTERNAL_LIBART_CO_FLAGS
|
||||
MOZ_INTERNAL_LIBART_CO_FLAGS=$(MOZ_CO_FLAGS)
|
||||
!endif
|
||||
|
||||
!if "$(MOZ_INTERNAL_LIBART_CO_TAG)" != ""
|
||||
MOZ_INTERNAL_LIBART_CO_FLAGS=$(MOZ_INTERNAL_LIBART_CO_FLAGS) -r $(MOZ_INTERNAL_LIBART_CO_TAG)
|
||||
!else
|
||||
MOZ_INTERNAL_LIBART_CO_FLAGS=$(MOZ_INTERNAL_LIBART_CO_FLAGS) $(CVS_BRANCH)
|
||||
!endif
|
||||
|
||||
CVSCO_MOZ_INTERNAL_LIBART = cvs $(CVS_FLAGS) co $(MOZ_INTERNAL_LIBART_CO_FLAGS)
|
||||
|
||||
!endif
|
||||
|
||||
## The master target
|
||||
############################################################
|
||||
|
||||
pull_and_build_all: pull_all build_all_dep
|
||||
|
||||
|
||||
## Rules for pulling the source from the cvs repository
|
||||
############################################################
|
||||
|
||||
pull_clobber_and_build_all: pull_all clobber_all build_all
|
||||
|
||||
!if !defined(MOZ_INTERNAL_LIBART_LGPL)
|
||||
pull_all: pull_nspr pull_psm pull_ldapcsdk pull_accessible pull_gfx2 pull_imglib2 pull_seamonkey
|
||||
!else
|
||||
pull_all: pull_nspr pull_psm pull_ldapcsdk pull_accessible pull_gfx2 pull_imglib2 pull_moz_internal_libart pull_seamonkey
|
||||
!endif
|
||||
|
||||
pull_nspr: pull_clientmak
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO_NSPR) mozilla/nsprpub
|
||||
|
||||
pull_nss:
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO_NSS) mozilla/security/coreconf
|
||||
$(CVSCO_NSS) mozilla/security/nss
|
||||
|
||||
pull_psm: pull_nss
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO_PSM) mozilla/security/manager
|
||||
$(CVSCO_PSM) mozilla/security/makefile.win
|
||||
|
||||
pull_ldapcsdk:
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO_LDAPCSDK) mozilla/directory/c-sdk
|
||||
|
||||
pull_accessible:
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO_ACCESSIBLE) mozilla/accessible
|
||||
|
||||
pull_gfx2:
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO_GFX2) mozilla/gfx2
|
||||
|
||||
pull_imglib2:
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO_IMGLIB2) mozilla/modules/libpr0n
|
||||
|
||||
!if defined(MOZ_INTERNAL_LIBART_LGPL)
|
||||
pull_moz_internal_libart:
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO_MOZ_INTERNAL_LIBART) mozilla/other-licenses/libart_lgpl
|
||||
!endif
|
||||
|
||||
pull_xpconnect: pull_nspr
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO) mozilla/include
|
||||
$(CVSCO) mozilla/config
|
||||
$(CVSCO) -l mozilla/js
|
||||
$(CVSCO) -l mozilla/js/src
|
||||
$(CVSCO) mozilla/js/src/fdlibm
|
||||
$(CVSCO) mozilla/js/src/xpconnect
|
||||
$(CVSCO) mozilla/modules/libreg
|
||||
$(CVSCO) mozilla/xpcom
|
||||
$(CVSCO) mozilla/string
|
||||
|
||||
# pull either layout only or seamonkey the browser
|
||||
pull_layout:
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO) RaptorWin
|
||||
|
||||
pull_seamonkey: pull_clientmak
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO) SeaMonkeyAll
|
||||
|
||||
pull_clientmak:
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO) mozilla/client.mak
|
||||
|
||||
############################################################
|
||||
|
||||
# nmake has to be hardcoded, or we have to depend on mozilla/config
|
||||
# being pulled already to figure out what $(NMAKE) should be.
|
||||
|
||||
clobber_all: clobber_nspr clobber_ldapcsdk clobber_psm clobber_seamonkey
|
||||
|
||||
build_all: build_nspr build_ldapcsdk build_seamonkey
|
||||
|
||||
build_all_dep: depend libs
|
||||
|
||||
distclean:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\directory\c-sdk
|
||||
gmake -f gmakefile.win distclean MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED)
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\nsprpub
|
||||
gmake -f gmakefile.win distclean MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED)
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)
|
||||
nmake /f client.mak clobber_psm
|
||||
nmake /f client.mak clobber_seamonkey
|
||||
|
||||
clobber_ldapcsdk:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\directory\c-sdk
|
||||
gmake -f gmakefile.win clobber_all MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED) \
|
||||
SHELL=sh
|
||||
|
||||
clobber_nspr:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\nsprpub
|
||||
gmake -f gmakefile.win clobber_all MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED)
|
||||
|
||||
clobber_psm:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\security
|
||||
nmake -f makefile.win clobber_all
|
||||
|
||||
clobber_xpconnect:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
|
||||
-rd /s /q dist
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\nsprpub
|
||||
gmake -f gmakefile.win clobber_all MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED)
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\include
|
||||
nmake -f makefile.win clobber_all
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\modules\libreg
|
||||
nmake -f makefile.win clobber_all
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\string
|
||||
nmake -f makefile.win clobber_all
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\xpcom
|
||||
nmake -f makefile.win clobber_all
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\js
|
||||
nmake -f makefile.win clobber_all
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\js\src\xpconnect
|
||||
nmake -f makefile.win clobber_all
|
||||
|
||||
clobber_seamonkey:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
|
||||
-rd /s /q dist
|
||||
nmake -f makefile.win clobber_all
|
||||
|
||||
depend: export
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
|
||||
nmake -f makefile.win depend
|
||||
|
||||
depend_xpconnect:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\include
|
||||
nmake -f makefile.win depend
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\modules\libreg
|
||||
nmake -f makefile.win depend
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\string
|
||||
nmake -f makefile.win depend
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\xpcom
|
||||
nmake -f makefile.win depend
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\js\src
|
||||
nmake -f makefile.win depend
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\js\src\xpconnect
|
||||
nmake -f makefile.win depend
|
||||
|
||||
build_nspr:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\nsprpub
|
||||
gmake -f gmakefile.win MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED)
|
||||
|
||||
build_ldapcsdk:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\directory\c-sdk
|
||||
gmake -f gmakefile.win MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED) SHELL=sh
|
||||
|
||||
build_psm:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\security
|
||||
nmake -f makefile.win
|
||||
|
||||
build_xpconnect: build_nspr
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\include
|
||||
nmake -f makefile.win all
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\modules\libreg
|
||||
nmake -f makefile.win all
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\xpcom
|
||||
nmake -f makefile.win export
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\string
|
||||
nmake -f makefile.win all
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\xpcom
|
||||
nmake -f makefile.win libs
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\js\src
|
||||
nmake -f makefile.win all
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\js\src\xpconnect
|
||||
nmake -f makefile.win all
|
||||
|
||||
build_seamonkey:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
|
||||
nmake -f makefile.win all
|
||||
|
||||
build_client:
|
||||
@cd $(MOZ_SRC)\mozilla\.
|
||||
nmake -f makefile.win all
|
||||
|
||||
build_layout:
|
||||
@cd $(MOZ_SRC)\mozilla\.
|
||||
nmake -f makefile.win all
|
||||
|
||||
build_dist:
|
||||
@cd $(MOZ_SRC)\mozilla\.
|
||||
nmake -f makefile.win all
|
||||
|
||||
libs:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
|
||||
nmake -f makefile.win libs
|
||||
|
||||
export: build_nspr build_ldapcsdk
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
|
||||
nmake -f makefile.win export
|
||||
|
||||
clobber_dist:
|
||||
@cd $(MOZ_SRC)\mozilla\.
|
||||
nmake -f makefile.win clobber_all
|
||||
|
||||
clobber_client:
|
||||
@cd $(MOZ_SRC)\mozilla\.
|
||||
nmake -f makefile.win clobber_all
|
||||
|
||||
clobber_layout:
|
||||
@cd $(MOZ_SRC)\mozilla\.
|
||||
nmake -f makefile.win clobber_all
|
||||
|
||||
browse_info::
|
||||
cd $(MOZ_SRC)\$(MOZ_TOP)
|
||||
-dir /s /b *.sbr > sbrlist.tmp
|
||||
-bscmake /Es /o mozilla.bsc @sbrlist.tmp
|
||||
-rm sbrlist.tmp
|
||||
|
||||
regchrome::
|
||||
@cd $(MOZ_SRC)\mozilla\.
|
||||
nmake /f makefile.win regchrome
|
||||
|
||||
deliver::
|
||||
@cd $(MOZ_SRC)\mozilla\.
|
||||
nmake /f makefile.win splitsymbols
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#// Utility stuff...
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
# Verify that MOZ_SRC is set correctly
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
# Check to see if it is set at all
|
||||
!if "$(MOZ_SRC)"==""
|
||||
MOZ_SRC = $(MAKEDIR)\..
|
||||
!endif
|
||||
|
||||
#
|
||||
# create a temp file at the root and make sure it is visible from MOZ_SRC
|
||||
#
|
||||
!if [copy $(MAKEDIR)\client.mak $(MAKEDIR)\xyzzy.tmp > NUL] == 0
|
||||
!endif
|
||||
|
||||
!if !EXIST( $(MOZ_SRC)\mozilla\xyzzy.tmp )
|
||||
ERR_MESSAGE=$(ERR_MESSAGE)^
|
||||
MOZ_SRC isn't set correctly: [$(MOZ_SRC)\mozilla]!=[$(MAKEDIR)]
|
||||
!endif
|
||||
|
||||
!if [del $(MAKEDIR)\xyzzy.tmp]
|
||||
!endif
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
# Verify that MOZ_BITS is set
|
||||
#//------------------------------------------------------------------------
|
||||
!if !defined(MOZ_BITS)
|
||||
ERR_MESSAGE=$(ERR_MESSAGE)^
|
||||
Environment variable MOZ_BITS isn't set.
|
||||
!endif
|
||||
|
||||
!if !defined(MOZ_TOOLS)
|
||||
ERR_MESSAGE=$(ERR_MESSAGE)^
|
||||
Environment variable MOZ_TOOLS isn't set.
|
||||
!endif
|
||||
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#// Display error
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
!if "$(ERR_MESSAGE)" != ""
|
||||
ERR_MESSAGE = ^
|
||||
client.mak: ^
|
||||
$(ERR_MESSAGE) ^
|
||||
^
|
||||
client.mak: usage^
|
||||
^
|
||||
nmake -f client.mak [MOZ_BRANCH=<cvs_branch_name>] ^
|
||||
[MOZ_DATE=<cvs_date>]^
|
||||
[pull_and_build_all]^
|
||||
[pull_all]^
|
||||
[build_all]^
|
||||
^
|
||||
Environment variables:^
|
||||
^
|
||||
MOZ_BITS set to 32^
|
||||
MOZ_TOOLS set to the directory containing the needed tools ^
|
||||
|
||||
!ERROR $(ERR_MESSAGE)
|
||||
|
||||
!endif
|
||||
@@ -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_0_RTM
|
||||
NSPR_CO_TAG = NETSCAPE_7_0_RTM
|
||||
PSM_CO_TAG = NETSCAPE_7_0_RTM
|
||||
NSS_CO_TAG = NETSCAPE_7_0_RTM
|
||||
LDAPCSDK_CO_TAG = NETSCAPE_7_0_RTM
|
||||
ACCESSIBLE_CO_TAG = NETSCAPE_7_0_RTM
|
||||
GFX2_CO_TAG = NETSCAPE_7_0_RTM
|
||||
IMGLIB2_CO_TAG = NETSCAPE_7_0_RTM
|
||||
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
|
||||
88
mozilla/directory/Makefile
Normal file
88
mozilla/directory/Makefile
Normal file
@@ -0,0 +1,88 @@
|
||||
#! gmake
|
||||
#
|
||||
# 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):
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
# You need to have checked out the LDAP tree at the same level as ns
|
||||
# in order to build LDAP.
|
||||
#
|
||||
|
||||
LDAP_DEPTH = .
|
||||
NSPR_TREE = ../nsprpub
|
||||
MOD_DEPTH = ../nsprpub
|
||||
NSPR_VERSION = 3.5.1
|
||||
DEPTH = ..
|
||||
|
||||
include $(NSPR_TREE)/config/rules.mk
|
||||
|
||||
all export:: FORCE
|
||||
@if [ -d $(NSPR_TREE)/ ]; then \
|
||||
cd $(NSPR_TREE); \
|
||||
$(MAKE); \
|
||||
else \
|
||||
echo "No NSPR $(NSPR_VERSION) directory found"; \
|
||||
exit 0; \
|
||||
fi
|
||||
@if [ -d $(LDAP_DEPTH)/c-sdk/ldap ]; then \
|
||||
cd $(LDAP_DEPTH)/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)/c-sdk/ldap ]; then \
|
||||
cd $(LDAP_DEPTH)/c-sdk/ldap; \
|
||||
$(MAKE) -f Makefile.client $(MFLAGS) install; \
|
||||
else \
|
||||
echo "No LDAP directory -- skipping"; \
|
||||
exit 0; \
|
||||
fi
|
||||
|
||||
clean clobber:: FORCE
|
||||
@if [ -d $(NSPR_TREE)/ ]; then \
|
||||
cd $(NSPR_TREE); \
|
||||
$(MAKE) clean; \
|
||||
else \
|
||||
echo "No NSPR $(NSPR_VERSION) directory found"; \
|
||||
exit 0; \
|
||||
fi
|
||||
@if [ -d $(LDAP_DEPTH)/c-sdk/ldap ]; then \
|
||||
cd $(LDAP_DEPTH)/c-sdk/ldap; \
|
||||
$(MAKE) -f Makefile.client $(MFLAGS) clean; \
|
||||
else \
|
||||
echo "No LDAP directory -- skipping"; \
|
||||
exit 0; \
|
||||
fi
|
||||
rm -rf ../dist
|
||||
|
||||
realclean clobber_all:: FORCE
|
||||
@if [ -d $(LDAP_DEPTH)/c-sdk/ldap ]; then \
|
||||
cd $(LDAP_DEPTH)/c-sdk/ldap; \
|
||||
$(MAKE) -f Makefile.client $(MFLAGS) realclean; \
|
||||
else \
|
||||
echo "No LDAP directory -- skipping"; \
|
||||
exit 0; \
|
||||
fi
|
||||
|
||||
FORCE:
|
||||
154
mozilla/directory/buildsdk.txt
Normal file
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)
|
||||
|
||||
34
mozilla/directory/c-sdk/ldap/Makefile.client
Normal file
34
mozilla/directory/c-sdk/ldap/Makefile.client
Normal file
@@ -0,0 +1,34 @@
|
||||
DEPTH = ../../..
|
||||
NSPR_TREE = ../../../nsprpub
|
||||
MOD_DEPTH = ../../../nsprpub
|
||||
|
||||
SRCDIRS = build include libraries
|
||||
|
||||
include $(NSPR_TREE)/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:
|
||||
|
||||
35
mozilla/directory/c-sdk/ldap/Makefile.in
Normal file
35
mozilla/directory/c-sdk/ldap/Makefile.in
Normal file
@@ -0,0 +1,35 @@
|
||||
DEPTH = ../../..
|
||||
srcdir = @srcdir@
|
||||
ldaptopsrcdir = @top_srcdir@
|
||||
|
||||
SRCDIRS = build include libraries
|
||||
|
||||
include build/autoconf.mk
|
||||
include $(NSPR_TREE)/config/rules.mk
|
||||
|
||||
all export:: FORCE
|
||||
@for i in $(SRCDIRS); do \
|
||||
echo " cd $$i; $(MAKE) $(MFLAGS) export"; \
|
||||
( cd $$i; $(MAKE) $(MFLAGS) export ); \
|
||||
done
|
||||
|
||||
libs install:: FORCE
|
||||
@for i in $(SRCDIRS); do \
|
||||
echo "cd $$i; $(MAKE) $(MFLAGS) install"; \
|
||||
( cd $$i; $(MAKE) $(MFLAGS) install ); \
|
||||
done
|
||||
|
||||
clean clobber:: FORCE
|
||||
@for i in $(SRCDIRS); do \
|
||||
echo "cd $$i; $(MAKE) $(MFLAGS) clean"; \
|
||||
( cd $$i; $(MAKE) $(MFLAGS) clean ); \
|
||||
done
|
||||
|
||||
realclean clobber_all:: FORCE
|
||||
@for i in $(SRCDIRS); do \
|
||||
echo "cd $$i; $(MAKE) $(MFLAGS) realclean"; \
|
||||
( cd $$i; $(MAKE) $(MFLAGS) realclean ); \
|
||||
done
|
||||
|
||||
FORCE:
|
||||
|
||||
31
mozilla/directory/c-sdk/ldap/README.configure
Normal file
31
mozilla/directory/c-sdk/ldap/README.configure
Normal file
@@ -0,0 +1,31 @@
|
||||
The autoconf files here are the barest shim to allow the LDAP C SDK to
|
||||
build with autoconf, including in a --objdir. These are really just a
|
||||
wrapper around the existing (NSPR-based) build-system; they propagate
|
||||
very little information from the autconf command line or environment.
|
||||
The Makefile.in files are all just slightly edited forks of the
|
||||
Makefile.client files. These files are:
|
||||
|
||||
Makefile.in
|
||||
configure
|
||||
configure.in
|
||||
build/Makefile.in
|
||||
build/autoconf.mk.in
|
||||
build/my_overrides.mk
|
||||
include/Makefile.in
|
||||
libraries/Makefile.in
|
||||
libraries/liblber/Makefile.in
|
||||
libraries/libldap/Makefile.in
|
||||
|
||||
Note that as in the main browser tree, I've checked in the (generated)
|
||||
configure script so that autoconf isn't a prerequisite to build.
|
||||
|
||||
At some point after the most current LDAP SDK code lands in Mozilla,
|
||||
then perhaps it will be worth spending some time creating a more
|
||||
correctly autoconfified build process that isn't just a shim and
|
||||
doesn't depend on NSPR.
|
||||
|
||||
Comments to <news://news.mozilla.org/netscape.public.mozilla.directory>,
|
||||
please.
|
||||
|
||||
Dan Mosedale
|
||||
<dmose@mozilla.org>
|
||||
28
mozilla/directory/c-sdk/ldap/build/Makefile.client
Normal file
28
mozilla/directory/c-sdk/ldap/build/Makefile.client
Normal file
@@ -0,0 +1,28 @@
|
||||
DEPTH = ../../../..
|
||||
MOD_DEPTH = ../../../../nsprpub
|
||||
NSPR_TREE = ../../../../nsprpub
|
||||
|
||||
CSRCS = dirver.c
|
||||
|
||||
include $(NSPR_TREE)/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
|
||||
|
||||
clean::
|
||||
rm -rf $(OBJDIR_NAME)
|
||||
|
||||
29
mozilla/directory/c-sdk/ldap/build/Makefile.in
Normal file
29
mozilla/directory/c-sdk/ldap/build/Makefile.in
Normal file
@@ -0,0 +1,29 @@
|
||||
DEPTH = ../../../..
|
||||
srcdir = @srcdir@
|
||||
ldaptopsrcdir = @top_srcdir@
|
||||
|
||||
CSRCS = dirver.c
|
||||
|
||||
include autoconf.mk
|
||||
include $(NSPR_TREE)/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
|
||||
|
||||
clean::
|
||||
rm -rf $(OBJDIR_NAME)
|
||||
|
||||
57
mozilla/directory/c-sdk/ldap/build/autoconf.mk.in
Normal file
57
mozilla/directory/c-sdk/ldap/build/autoconf.mk.in
Normal file
@@ -0,0 +1,57 @@
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org LDAP SDK autoconf glue.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Commmunications Corp. Portions created by Netscape are
|
||||
# Copyright (C) 2000, Netscape Communications Corp. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Dan Mosedale <dmose@mozilla.org>
|
||||
#
|
||||
|
||||
# this is used to override DIST and VPATH
|
||||
#
|
||||
NSPR_MY_OVERRIDES_MK = $(ldaptopsrcdir)/build/my_overrides.mk
|
||||
|
||||
# common to all the ldap sdk makefiles
|
||||
#
|
||||
NSPR_TREE = $(ldaptopsrcdir)/../../../nsprpub
|
||||
topsrcdir = $(ldaptopsrcdir)/../../../nsprpub
|
||||
|
||||
# various stuff from the ldap sdk documentation
|
||||
#
|
||||
MOZILLA_CLIENT = 1
|
||||
NO_MDUPDATE = 1
|
||||
MOZ_LDAP_SDK = 1
|
||||
MOZ_LI =
|
||||
MOZ_LITE =
|
||||
MOZ_MEDIUM =
|
||||
NO_SECURITY =
|
||||
|
||||
# we have to cope if nspr was built using autoconf (which we only know is
|
||||
# is true if our configure was passed --enable-nspr-autoconf -- which
|
||||
# the top-level configure does automagically, as appropriate).
|
||||
#
|
||||
NSPR_USE_AUTOCONF = @NSPR_USE_AUTOCONF@
|
||||
|
||||
ifeq ($(NSPR_USE_AUTOCONF), 1)
|
||||
|
||||
MOD_DEPTH = $(DEPTH)
|
||||
include $(DEPTH)/nsprpub/config/autoconf.mk
|
||||
VPATH = $(srcdir)
|
||||
DIST = $(DEPTH)/dist
|
||||
|
||||
else
|
||||
MOD_DEPTH = $(NSPR_TREE)
|
||||
|
||||
endif
|
||||
217
mozilla/directory/c-sdk/ldap/build/dirver.c
Normal file
217
mozilla/directory/c-sdk/ldap/build/dirver.c
Normal file
@@ -0,0 +1,217 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
/ 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
|
||||
#ifdef macintosh
|
||||
#include <console.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 < 1900) /* they really mean 1900 + nYear */
|
||||
nYear += 1900;
|
||||
|
||||
nYear -= 1980;
|
||||
nBuildDate = nYear;
|
||||
/*
|
||||
nBuildDate <<= 5;
|
||||
*/
|
||||
nBuildDate <<= 4;
|
||||
nBuildDate += nMonth;
|
||||
/* nBuildDate <<= 4; */
|
||||
nBuildDate <<= 5;
|
||||
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);
|
||||
nMonth--; /* use months in the range [0..11], as in struct tm */
|
||||
if(szToken = strtok(NULL, "\\/"))
|
||||
{
|
||||
nDay = atoi(szToken);
|
||||
if(szToken = strtok(NULL, "\\/"))
|
||||
{
|
||||
nYear = atoi(szToken);
|
||||
if(nYear < 70) { /* handle 2 digit years like (20)00 */
|
||||
nYear += 100;
|
||||
}
|
||||
else if (nYear < 100) {
|
||||
}
|
||||
else if (nYear > 1900){
|
||||
nYear -= 1900;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
#ifdef macintosh
|
||||
nArgc = ccommand( &lpArgv );
|
||||
#endif
|
||||
|
||||
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) {
|
||||
if (( f = fopen(szOutput, "w")) == NULL ) {
|
||||
perror( szOutput );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(f, "#define VI_PRODUCTVERSION %u.%u\n", nMajor, nMinor);
|
||||
fprintf(f, "#define PRODUCTTEXT \"%s\"\n", szVersion );
|
||||
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);
|
||||
}
|
||||
|
||||
23
mozilla/directory/c-sdk/ldap/build/my_overrides.mk
Normal file
23
mozilla/directory/c-sdk/ldap/build/my_overrides.mk
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org LDAP SDK autoconf glue.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Commmunications Corp. Portions created by Netscape are
|
||||
# Copyright (C) 2000, Netscape Communications Corp. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Dan Mosedale <dmose@mozilla.org>
|
||||
#
|
||||
|
||||
DIST = $(DEPTH)/dist
|
||||
VPATH = $(srcdir)
|
||||
469
mozilla/directory/c-sdk/ldap/clients/tools/Makefile
Normal file
469
mozilla/directory/c-sdk/ldap/clients/tools/Makefile
Normal file
@@ -0,0 +1,469 @@
|
||||
#
|
||||
# GNU Makefile for LDAP client tools.
|
||||
#
|
||||
|
||||
LDAP_SRC = ../..
|
||||
MCOM_ROOT = ../../../..
|
||||
|
||||
NOSTDCLEAN=true # don't let nsconfig.mk define target clean
|
||||
NOSTDSTRIP=true # don't let nsconfig.mk define target strip
|
||||
NSPR20=true # probably should be defined somewhere else (not sure where)
|
||||
|
||||
OBJDEST = $(OBJDIR)/clients/tools/obj
|
||||
BINDIR = $(OBJDIR)/clients/bin
|
||||
|
||||
include $(MCOM_ROOT)/c-sdk/nsdefs.mk
|
||||
include $(MCOM_ROOT)/c-sdk/nsconfig.mk
|
||||
|
||||
include $(LDAP_SRC)/nsldap.mk
|
||||
ifndef LDAP_USE_OLD_DB
|
||||
include $(MCOM_ROOT)/c-sdk/ns_usedb.mk
|
||||
endif
|
||||
|
||||
# NLS Library
|
||||
|
||||
NLS_COMP_NAME = libnls
|
||||
NLS_VERS_NUM = 31
|
||||
NLS_COMP_DIR = $(NLS_COMP_NAME)$(NLS_VERS_NUM)
|
||||
NLS_ROOT = $(MCOM_ROOT)/../components/$(NLS_COMP_DIR)
|
||||
|
||||
NLS_LIBPATH = $(NLS_ROOT)/$(NLSOBJDIR)/lib
|
||||
NLS_INCLUDE = $(NLS_ROOT)/$(NLSOBJDIR)/include
|
||||
NLS_LOCALE = $(NLS_ROOT)/$(NLSOBJDIR)/locale$(NLS_VERS_NUM)
|
||||
NLS_CONV = $(NLS_ROOT)/$(NLSOBJDIR)/conv$(NLS_VERS_NUM)
|
||||
NLS_VERSION_FILE = $(NLS_ROOT)/Version
|
||||
|
||||
|
||||
NLS_RELDATE=v3.2
|
||||
|
||||
NLS_VERSION = $(NLS_RELDATE)
|
||||
|
||||
ifeq ($(ARCH), WINNT)
|
||||
ifeq ($(OS_TARGET), WIN95)
|
||||
ifeq ($(DEBUG), full)
|
||||
NLSOBJDIR = WIN954.0_DBG.OBJ
|
||||
else
|
||||
ifeq ($(DEBUG), fulld)
|
||||
NLSOBJDIR = WIN954.0_DBG.OBJD
|
||||
else
|
||||
NLSOBJDIR = WIN954.0_OPT.OBJ
|
||||
endif
|
||||
endif
|
||||
else
|
||||
ifeq ($(DEBUG), full)
|
||||
NLSOBJDIR = WINNT4.0_DBG.OBJ
|
||||
else
|
||||
ifeq ($(DEBUG), fulld)
|
||||
NLSOBJDIR = WINNT4.0_DBG.OBJD
|
||||
else
|
||||
NLSOBJDIR = WINNT4.0_OPT.OBJ
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
NLS_RELEASE = $(COMPONENTS_DIR)/libnls$(NLS_VERS_NUM)/$(NLS_VERSION)/$(NLSOBJDIR)
|
||||
# NLS_LIBNAMES = brk32$(NLS_VERS_NUM) cnv32$(NLS_VERS_NUM) col32$(NLS_VERS_NUM) fmt32$(NLS_VERS_NUM) res32$(NLS_VERS_NUM) uni32$(NLS_VERS_NUM)
|
||||
NLS_LIBNAMES = cnv32$(NLS_VERS_NUM)
|
||||
NLS_CONV_LIBNAMES = jpn32$(NLS_VERS_NUM) cck32$(NLS_VERS_NUM) sb32$(NLS_VERS_NUM)
|
||||
NLS_LIBS = $(addsuffix .lib, $(addprefix ns, $(NLS_LIBNAMES)))
|
||||
NLS_CONV_LIBS = $(addsuffix .lib, $(addprefix ns, $(NLS_CONV_LIBNAMES)))
|
||||
NLSDLL_NAMES = $(addsuffix .dll, $(addprefix ns, $(NLS_LIBNAMES)))
|
||||
NLS_CONVDLL_NAMES = $(addsuffix .dll, $(addprefix ns, $(NLS_CONV_LIBNAMES)))
|
||||
LIBNLS = $(addprefix $(NLS_LIBPATH)/, $(NLS_LIBS))
|
||||
LIBNLS_CONV = $(addprefix $(NLS_LIBPATH)/, $(NLS_CONV_LIBS))
|
||||
NLSOBJNAME = $(NLS_LIBNAMES)
|
||||
else
|
||||
ifeq ($(ARCH), HPUX)
|
||||
ifeq ($(NSOS_RELEASE), B.11.00)
|
||||
NLSOBJDIR = $(NSOBJDIR_NAME)
|
||||
NLS_RELEASE = $(COMPONENTS_DIR)/libnls$(NLS_VERS_NUM)/$(NLS_VERSION)/$(NLSOBJDIR)
|
||||
else
|
||||
NLSOBJDIR = $(NSOBJDIR_NAME)
|
||||
NLS_RELEASE = $(COMPONENTS_DIR)/libnls$(NLS_VERS_NUM)/$(NLS_VERSION)/$(NLSOBJDIR)
|
||||
endif
|
||||
else
|
||||
# Here is a hack to replace _PTH with n32, this must be done before
|
||||
# the _PTH substitustion
|
||||
|
||||
ifeq ($(ARCH),IRIX)
|
||||
ifeq ($(USE_N32),1)
|
||||
NLSOBJDIR = $(NSOBJDIR_NAME2_NOTAG)
|
||||
else
|
||||
NLSOBJDIR = $(NSOBJDIR_NAME_NOTAG)
|
||||
endif
|
||||
else
|
||||
NLSOBJDIR = $(NSOBJDIR_NAME_NOTAG)
|
||||
|
||||
ifeq ($(ARCH), OSF1)
|
||||
NLSOBJDIR = $(NSOBJDIR_NAME)
|
||||
endif
|
||||
endif
|
||||
|
||||
# NLS Does not has PTH version, so here is the hack which treat non PTH
|
||||
# version as PTH version
|
||||
ifeq ($(USE_PTHREADS), 1)
|
||||
NLS_RELEASE = $(COMPONENTS_DIR)/libnls$(NLS_VERS_NUM)/$(NLS_VERSION)/$(NLSOBJDIR)
|
||||
else
|
||||
NLS_RELEASE = $(COMPONENTS_DIR)/libnls$(NLS_VERS_NUM)/$(NLS_VERSION)/$(NLSOBJDIR)
|
||||
endif
|
||||
endif # HPUX
|
||||
NLS_LIBNAMES = cnv$(NLS_VERS_NUM)
|
||||
NLS_CONV_LIBNAMES = jpn$(NLS_VERS_NUM) cck$(NLS_VERS_NUM) sb$(NLS_VERS_NUM)
|
||||
NLS_SOLIB_NAMES = $(addsuffix $(DLL_PRESUF), $(addprefix libns, $(NLS_LIBNAMES)))
|
||||
NLS_CONV_SOLIB_NAMES = $(addsuffix $(DLL_PRESUF), $(addprefix libns, $(NLS_CONV_LIBNAMES)))
|
||||
NLS_LIBS = $(addsuffix .a, $(NLS_SOLIB_NAMES))
|
||||
NLS_CONV_LIBS = $(addsuffix .a, $(NLS_CONV_SOLIB_NAMES))
|
||||
NLS_SOLIBS = $(addsuffix .$(DLL_SUFFIX), $(NLS_SOLIB_NAMES))
|
||||
NLS_CONV_SOLIBS = $(addsuffix .$(DLL_SUFFIX), $(NLS_CONV_SOLIB_NAMES))
|
||||
NLSOBJNAME = $(NLS_SOLIBS)
|
||||
LIBNLS = $(addprefix $(NLS_LIBPATH)/, $(NLS_SOLIBS))
|
||||
|
||||
ifeq ($(ARCH), OSF1)
|
||||
NLSLINK = -L$(NLS_LIBPATH) $(addprefix -l, $(addsuffix $(DLL_PRESUF), $(addprefix ns, $(NLS_LIBNAMES)))) -lcxx
|
||||
NLSLINK_STATIC = $(addprefix $(NLS_LIBPATH)/, $(NLS_LIBS)) -lcxx
|
||||
NLSLINK_CONV_STATIC = $(addprefix $(NLS_LIBPATH)/, $(NLS_CONV_LIBS))
|
||||
else
|
||||
ifeq ($(ARCH),HPUX)
|
||||
#linking with libC is *BAD* on HPUX11
|
||||
NLSLINK = -L$(NLS_LIBPATH) $(addprefix -l, $(addsuffix $(DLL_PRESUF), $(addprefix ns, $(NLS_LIBNAMES))))
|
||||
NLSLINK_STATIC = $(addprefix $(NLS_LIBPATH)/, $(NLS_LIBS))
|
||||
NLSLINK_CONV_STATIC = $(addprefix $(NLS_LIBPATH)/, $(NLS_CONV_LIBS))
|
||||
else
|
||||
ifeq ($(ARCH),Linux)
|
||||
NLSLINK = -L$(NLS_LIBPATH) $(addprefix -l, $(addsuffix $(DLL_PRESUF), $(addprefix ns, $(NLS_LIBNAMES)))) -lresolv -lpthread
|
||||
NLSLINK_STATIC = $(addprefix $(NLS_LIBPATH)/, $(NLS_LIBS)) -lresolv -lpthread
|
||||
else
|
||||
ifeq ($(ARCH),IRIX)
|
||||
NLSLINK = -L$(NLS_LIBPATH) $(addprefix -l, $(addsuffix $(DLL_PRESUF), $(addprefix ns, $(NLS_LIBNAMES)))) -lpthread
|
||||
NLSLINK_STATIC = $(addprefix $(NLS_LIBPATH)/, $(NLS_LIBS)) -lpthread
|
||||
else
|
||||
NLSLINK = -L$(NLS_LIBPATH) $(addprefix -l, $(addsuffix $(DLL_PRESUF), $(addprefix ns, $(NLS_LIBNAMES)))) -lC
|
||||
NLSLINK_STATIC = $(addprefix $(NLS_LIBPATH)/, $(NLS_LIBS)) -lC
|
||||
endif # Irix
|
||||
endif # Linux
|
||||
NLSLINK_CONV_STATIC = $(addprefix $(NLS_LIBPATH)/, $(NLS_CONV_LIBS))
|
||||
endif # HPUX
|
||||
endif # OSF1
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH), SOLARIS)
|
||||
NLSLINK += -lw
|
||||
endif
|
||||
|
||||
$(LIBNLS): $(NLS_VERSION_FILE) nls_version_check
|
||||
|
||||
$(NLS_VERSION_FILE):
|
||||
mkdir -p $(NLS_ROOT); \
|
||||
cd $(NLS_ROOT); echo "garbage" > Version
|
||||
|
||||
ifneq ($(ARCH), WINNT)
|
||||
ifndef FORCE_FTP
|
||||
nls_version_check:
|
||||
@if [ `cat $(NLS_VERSION_FILE)` != "$(NLS_VERSION)" -o ! -d $(NLS_ROOT)/$(NLSOBJDIR) ]; then \
|
||||
if [ -d $(NLS_RELEASE) ]; then \
|
||||
if [ "$(RELEASE_TREE)" != "" ]; then \
|
||||
(cd $(NLS_ROOT); \
|
||||
\rm -rf $(NLSOBJDIR) $(NLS_VERSION_FILE); \
|
||||
ln -s $(RELEASE_TREE)/libnls31/$(NLSOBJDIR) $(NLSOBJDIR)); \
|
||||
echo "$(NLS_VERSION)" > $(NLS_VERSION_FILE); \
|
||||
else \
|
||||
(cd $(NLS_ROOT); \
|
||||
\rm -rf $(NLSOBJDIR) $(NLS_VERSION_FILE); \
|
||||
ln -s $(NLS_RELEASE) $(NLSOBJDIR)); \
|
||||
echo "$(NLS_VERSION)" > $(NLS_VERSION_FILE); \
|
||||
fi; \
|
||||
else \
|
||||
echo "************************** ERROR *************************"; \
|
||||
echo "LIBNLS client libraries are missing. Make sure your machine"; \
|
||||
echo "has access to $(NLS_RELEASE)"; \
|
||||
echo "**********************************************************"; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
fi; \
|
||||
|
||||
else
|
||||
|
||||
nls_version_check:
|
||||
# The following shell script recalculates $(NLS_INCLUDE), $(NLS_LIBPATH) and
|
||||
# $(NLS_VERSION_FILE)
|
||||
sh $(MCOM_ROOT)/c-sdk/compver.sh $(NLS_ROOT) $(NLS_VERSION) \
|
||||
$(NLSOBJDIR) $(MCOM_ROOT) $(MODULE) $(NLS_RELEASE) libnls$(NLS_VERS_NUM) \
|
||||
"' include lib conv$(NLS_VERS_NUM) locale$(NLS_VERS_NUM) '" $(NLS_ROOT)/$(NLSOBJDIR)/locale$(NLS_VERS_NUM)/index.txt
|
||||
endif
|
||||
else
|
||||
|
||||
nls_version_check:
|
||||
# The following shell script recalculates $(NLS_INCLUDE), $(NLS_LIBPATH) and
|
||||
# $(NLS_VERSION_FILE)
|
||||
sh $(MCOM_ROOT)/c-sdk/compver.sh $(NLS_ROOT) $(NLS_VERSION) \
|
||||
$(NLSOBJDIR) $(MCOM_ROOT) ldapsdk $(NLS_RELEASE) \
|
||||
libnls$(NLS_VERS_NUM) \
|
||||
"' include lib conv$(NLS_VERS_NUM) locale$(NLS_VERS_NUM) '" \
|
||||
$(NLS_ROOT)/$(NLSOBJDIR)/locale$(NLS_VERS_NUM)/index.txt
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH), HPUX)
|
||||
ifeq ($(NSOS_RELEASE), B.11.00)
|
||||
EXTRA_LIBS += -lrt
|
||||
CXX=aCC -DHPUX_ACC -D__STDC_EXT__ -D_POSIX_C_SOURCE=199506L
|
||||
LINK_EXE_NOLIBSOBJS_NOCXX = $(CXX) -Wl,-E $(ALDFLAGS) $(LDFLAGS) \
|
||||
$(RPATHFLAG_PREFIX)$(RPATHFLAG) -o $@
|
||||
LINK_EXE_NOCXX = $(CXX) -Wl,-E $(ALDFLAGS) $(LDFLAGS) \
|
||||
$(RPATHFLAG_PREFIX)$(RPATHFLAG) -o $@ $(OBJS) $(EXTRA_LIBS)
|
||||
endif
|
||||
ifeq ($(NSOS_RELEASE), B.11.00_64)
|
||||
EXTRA_LIBS += -lrt
|
||||
CXX=aCC -DHPUX_ACC -D__STDC_EXT__ -D_POSIX_C_SOURCE=199506L +DA2.0W +DS2.0
|
||||
LINK_EXE_NOLIBSOBJS_NOCXX = $(CXX) -Wl,-E $(ALDFLAGS) $(LDFLAGS) \
|
||||
$(RPATHFLAG_PREFIX)$(RPATHFLAG) -o $@
|
||||
LINK_EXE_NOCXX = $(CXX) -Wl,-E $(ALDFLAGS) $(LDFLAGS) \
|
||||
$(RPATHFLAG_PREFIX)$(RPATHFLAG) -o $@ $(OBJS) $(EXTRA_LIBS)
|
||||
endif
|
||||
ifeq ($(NSOS_RELEASE), B.10.10)
|
||||
CC= CC +a1
|
||||
# CXX=CC -D__STDC_EXT__
|
||||
# $(subst "+e", "",$(CFLAGS))
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH),Linux)
|
||||
CXX = egcs
|
||||
LINK_EXE = $(CXX) $(ALDFLAGS) $(LDFLAGS) \
|
||||
$(RPATHFLAG_PREFIX)$(RPATHFLAG)$(RPATHFLAG_EXTRAS) \
|
||||
-o $@ $(OBJS) $(EXTRA_LIBS)
|
||||
LINK_EXE_NOLIBSOBJS = $(CXX) $(ALDFLAGS) $(LDFLAGS) \
|
||||
$(RPATHFLAG_PREFIX)$(RPATHFLAG)$(RPATHFLAG_EXTRAS) -o $@
|
||||
|
||||
else
|
||||
ifeq ($(ARCH), OSF1)
|
||||
ifdef USE_LD_RUN_PATH
|
||||
#does RPATH differently. instead we export RPATHFLAG as LD_RUN_PATH
|
||||
#see ns/c-sdk/ldap/clients/tools/Makefile for an example
|
||||
export LD_RUN_PATH=$(RPATHFLAG)
|
||||
LINK_EXE = $(CXX) $(ALDFLAGS) $(LDFLAGS) \
|
||||
-o $@ $(OBJS) $(EXTRA_LIBS)
|
||||
LINK_EXE_NOLIBSOBJS = $(CXX) $(ALDFLAGS) $(LDFLAGS) -o $@
|
||||
else # USE_LD_RUN_PATH
|
||||
LINK_EXE = $(CXX) $(ALDFLAGS) $(LDFLAGS) \
|
||||
$(RPATHFLAG_PREFIX)$(RPATHFLAG)$(RPATHFLAG_EXTRAS) \
|
||||
-o $@ $(OBJS) $(EXTRA_LIBS)
|
||||
LINK_EXE_NOLIBSOBJS = $(CXX) $(ALDFLAGS) $(LDFLAGS) \
|
||||
$(RPATHFLAG_PREFIX)$(RPATHFLAG)$(RPATHFLAG_EXTRAS) -o $@
|
||||
endif # USE_LD_RUN_PATH
|
||||
endif
|
||||
endif
|
||||
MCOM_INCLUDE += -I$(NLS_INCLUDE)
|
||||
|
||||
INCLUDES += $(SSLINCLUDE) $(NO_LIBLCACHE)
|
||||
DEFS += $(SSL)
|
||||
|
||||
ALDFLAGS += $(SSLLIBFLAG)
|
||||
|
||||
ifeq ($(ARCH), WINNT)
|
||||
SUBSYSTEM=console
|
||||
endif
|
||||
|
||||
ifneq ($(ARCH), WINNT)
|
||||
# Run-time search path for shared libraries: in admin server 3.x installations,
|
||||
# the ldap tools get installed under NSHOME/userdb/ldap/tools and the LDAP SDK
|
||||
# libraries (libldap and liblcache) get installed under NSHOME/lib, so the
|
||||
# correct library search path is ../../../lib. We also want to search
|
||||
# NSHOME/bin/slapd, where more recent versions of the SDK so's may be.
|
||||
RPATHFLAG=..:../lib:../../lib:../../../lib:../../../../lib
|
||||
ifdef USE_LD_RUN_PATH
|
||||
LD_RUN_PATH=$(RPATHFLAG)
|
||||
export LD_RUN_PATH
|
||||
endif
|
||||
endif
|
||||
|
||||
# svrcore is used by ntpinobj, and pinarg handling
|
||||
LIBSVRCORE_DEP= $(NSCP_DISTDIR)/lib/svrcore.$(LIB_SUFFIX)
|
||||
ifeq ($(ARCH), WINNT)
|
||||
LIBSVRCORE= $(NSCP_DISTDIR)/lib/svrcore.$(LIB_SUFFIX)
|
||||
else
|
||||
LIBSVRCORE = -lsvrcore
|
||||
endif
|
||||
|
||||
ifeq ($(INCLUDE_SSL),1)
|
||||
# libsec and friends are already in libldap, so don't link with them here
|
||||
LDTOOLS_LIBS_DEP = $(LDAP_SDK_LIBLDAP_DLL_DEP) $(EXTRA_LIBS_DEP)
|
||||
LDTOOLS_LIBS = $(LDAP_SDK_LIBLDAP_DLL)
|
||||
ifneq ($(LDAP_NO_LIBLCACHE),1)
|
||||
LDTOOLS_LIBS_DEP += $(LDAP_LIBLDIF_DEP)
|
||||
LDTOOLS_LIBS += $(LDAP_LIBLDIF) $(LDAP_SDK_LIBLCACHE_DLL)
|
||||
else
|
||||
LDTOOLS_LIBS_DEP += $(LDAP_LIBLDIF_DEP)
|
||||
LDTOOLS_LIBS += $(LDAP_LIBLDIF)
|
||||
endif
|
||||
|
||||
LDTOOLS_LIBS += $(EXTRA_LIBS) $(EXTRA_MALLOC_LIBS) $(LDAP_SDK_LIBLDAP_DLL) $(LIBSVRCORE)
|
||||
|
||||
# XXXceb The linker on NT is auto optimizing. We still need to have libsec around for svrcore
|
||||
# Do Not Mess with the link order. This was not straightforward, and "optimizing" the text
|
||||
# will break the builds.
|
||||
ifeq ($(ARCH), WINNT)
|
||||
LDTOOLS_LIBS += $(LIBSEC)
|
||||
endif
|
||||
ifeq ($(ARCH), SOLARIS)
|
||||
LDTOOLS_LIBS += $(LIBSEC) $(LIBDB)
|
||||
endif
|
||||
ifeq ($(ARCH), HPUX)
|
||||
LDTOOLS_LIBS += $(LIBSEC)
|
||||
endif
|
||||
ifeq ($(ARCH), IRIX)
|
||||
LDTOOLS_LIBS += $(LIBSEC) $(LIBDB)
|
||||
endif
|
||||
ifeq ($(ARCH), AIX)
|
||||
LDTOOLS_LIBS += $(LIBSEC) $(LIBDB)
|
||||
endif
|
||||
ifeq ($(ARCH), WINNT)
|
||||
LDTOOLS_LIBS += $(LIBNSPR)
|
||||
else
|
||||
LDTOOLS_LIBS += $(DYNAMICNSPR)
|
||||
endif
|
||||
else
|
||||
# SSL is not included in the LDAP shared library...
|
||||
# need to link with libsec and friends explicitly
|
||||
LDTOOLS_LIBS_DEP = $(LDAP_SDK_LIBS_DEP) $(LDAP_LIBLDIF_DEP) \
|
||||
$(EXTRA_LIBS_DEP)
|
||||
LDTOOLS_LIBS_DEP += $(LDAP_LIBLDIF_DEP)
|
||||
ifeq ($(ARCH), OSF1)
|
||||
LDTOOLS_LIBS = $(LDAP_SDK_LIBSSLDAP_LIB) $(LDAP_SDK_LIBLDAP_DLL) $(LDAP_SDK_LIBPRLDAP_DLL)
|
||||
else
|
||||
LDTOOLS_LIBS = $(LDAP_SDK_LIBSSLDAP_LIB) $(LDAP_SDK_LIBPRLDAP_DLL) $(LDAP_SDK_LIBLDAP_DLL)
|
||||
endif
|
||||
ifneq ($(LDAP_NO_LIBLCACHE),1)
|
||||
LDTOOLS_LIBS += $(LDAP_SDK_LIBLCACHE_DLL)
|
||||
endif
|
||||
LDTOOLS_LIBS += $(LIBSVRCORE) $(LIBSEC) $(LIBDB) $(EXTRA_LIBS)\
|
||||
$(EXTRA_MALLOC_LIBS) $(LDAP_LIBLDIF)
|
||||
|
||||
ifneq ($(LDAP_NO_LIBLCACHE),1)
|
||||
ifndef LDAP_USE_OLD_DB
|
||||
LDTOOLS_LIBS_DEP+=$(DB_LIB_DEP)
|
||||
LDTOOLS_LIBS+=$(DB_LIB)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(LDAP_NO_LIBLCACHE),1)
|
||||
CFLAGS+=-DNO_LIBLCACHE
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH), WINNT)
|
||||
LDTOOLS_LIBS += $(LIBNSPR)
|
||||
else
|
||||
LDTOOLS_LIBS += $(DYNAMICNSPR)
|
||||
endif
|
||||
|
||||
# INCLUDE_SSL
|
||||
endif
|
||||
|
||||
LDTOOLS_LIBS_DEP += $(LIBNLS)
|
||||
ifeq ($(ARCH), WINNT)
|
||||
LDTOOLS_LIBS += $(LIBNLS) $(LIBNLS_CONV)
|
||||
else
|
||||
LDTOOLS_LIBS += $(NLSLINK_STATIC) $(NLSLINK_CONV_STATIC)
|
||||
endif
|
||||
|
||||
|
||||
|
||||
|
||||
#LDTOOLS_LIBS += $(LIBSVRCORE)
|
||||
|
||||
ifeq ($(ARCH), AIX)
|
||||
LDTOOLS_LIBS += $(EXE_EXTRA_LIBS)
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH), WINNT)
|
||||
ALDFLAGS += -FORCE:MULTIPLE /NODEFAULTLIB:MSVCRTD
|
||||
endif
|
||||
|
||||
#ifeq ($(ARCH), HPUX)
|
||||
#CC=CC +a1
|
||||
#LINK_EXE = $(LINK_EXE_NOCXX)
|
||||
#endif
|
||||
|
||||
ifeq ($(ARCH),IRIX)
|
||||
ifeq ($(USE_N32),1)
|
||||
CXX=CC
|
||||
LDFLAGS += -n32 -mips3
|
||||
CC=cc
|
||||
LINK_EXE = $(CXX) $(ALDFLAGS) $(LDFLAGS) \
|
||||
-o $@ $(OBJS) $(EXTRA_LIBS)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH), SOLARIS)
|
||||
ifeq ($(USE_64), 1)
|
||||
LINK_EXE += -xarch=v9 -L/usr/lib/sparcv9 -lCrun
|
||||
else
|
||||
LINK_EXE += -xarch=v8
|
||||
endif
|
||||
endif
|
||||
|
||||
LINK_EXE += -$(LIBPATH)../$(MCOM_ROOT)/dist/$(NC_BUILD_FLAVOR)/lib
|
||||
|
||||
LDAPDELETE_OBJ = $(addprefix $(OBJDEST)/, ldapdelete.o)
|
||||
LDAPMODIFY_OBJ = $(addprefix $(OBJDEST)/, ldapmodify.o fileurl.o)
|
||||
LDAPMODRDN_OBJ = $(addprefix $(OBJDEST)/, ldapmodrdn.o)
|
||||
LDAPSEARCH_OBJ = $(addprefix $(OBJDEST)/, ldapsearch.o fileurl.o)
|
||||
LDAPCMP_OBJ = $(addprefix $(OBJDEST)/, ldapcmp.o)
|
||||
LDAPTOOLCOMMON_OBJ = $(addprefix $(OBJDEST)/, common.o convutf8.o argpin.o ntuserpin.o)
|
||||
|
||||
CLIENT_OBJS = $(LDAPDELETE_OBJ) $(LDAPMODIFY_OBJ) $(LDAPMODRDN_OBJ) \
|
||||
$(LDAPSEARCH_OBJ) $(LDAPCMP_OBJ) $(LDAPTOOLCOMMON_OBJ)
|
||||
|
||||
LDAPDELETE = $(addsuffix $(EXE_SUFFIX), $(addprefix $(BINDIR)/, ldapdelete))
|
||||
LDAPMODIFY = $(addsuffix $(EXE_SUFFIX), $(addprefix $(BINDIR)/, ldapmodify))
|
||||
LDAPMODRDN = $(addsuffix $(EXE_SUFFIX), $(addprefix $(BINDIR)/, ldapmodrdn))
|
||||
LDAPSEARCH = $(addsuffix $(EXE_SUFFIX), $(addprefix $(BINDIR)/, ldapsearch))
|
||||
LDAPADD = $(addsuffix $(EXE_SUFFIX), $(addprefix $(BINDIR)/, ldapadd))
|
||||
LDAPCMP = $(addsuffix $(EXE_SUFFIX), $(addprefix $(BINDIR)/, ldapcmp))
|
||||
|
||||
BINS= $(LDAPDELETE) $(LDAPMODIFY) $(LDAPSEARCH) $(LDAPCMP)
|
||||
|
||||
all: $(OBJDEST) $(BINDIR) $(BINS)
|
||||
cmp: $(LDAPCMP)
|
||||
|
||||
$(LDAPTOOLCOMMON_OBJ): $(LIBNLS)
|
||||
|
||||
$(LDAPDELETE): $(LDAPDELETE_OBJ) $(LDAPTOOLCOMMON_OBJ) $(LDTOOLS_LIBS_DEP)
|
||||
$(LINK_EXE) $(LDAPDELETE_OBJ) $(LDAPTOOLCOMMON_OBJ) $(LDTOOLS_LIBS)
|
||||
|
||||
$(LDAPMODIFY): $(LDAPMODIFY_OBJ) $(LDAPTOOLCOMMON_OBJ) $(LDTOOLS_LIBS_DEP)
|
||||
$(LINK_EXE) $(LDAPMODIFY_OBJ) $(LDAPTOOLCOMMON_OBJ) $(LDTOOLS_LIBS)
|
||||
|
||||
$(LDAPMODRDN): $(LDAPMODRDN_OBJ) $(LDAPTOOLCOMMON_OBJ) $(LDTOOLS_LIBS_DEP)
|
||||
$(LINK_EXE) $(LDAPMODRDN_OBJ) $(LDAPTOOLCOMMON_OBJ) $(LDTOOLS_LIBS)
|
||||
|
||||
$(LDAPSEARCH): $(LDAPSEARCH_OBJ) $(LDAPTOOLCOMMON_OBJ) $(LDTOOLS_LIBS_DEP)
|
||||
$(LINK_EXE) $(LDAPSEARCH_OBJ) $(LDAPTOOLCOMMON_OBJ) $(LDTOOLS_LIBS)
|
||||
|
||||
$(LDAPADD): $(LDAPMODIFY) $(LDTOOLS_LIBS_DEP)
|
||||
$(RM) $(LDAPADD)
|
||||
$(HARDLN) $(LDAPMODIFY) $(LDAPADD)
|
||||
|
||||
$(LDAPCMP): $(LDAPCMP_OBJ) $(LDAPTOOLCOMMON_OBJ) $(LDTOOLS_LIBS_DEP)
|
||||
$(LINK_EXE) $(LDAPCMP_OBJ) $(LDAPTOOLCOMMON_OBJ) $(LDTOOLS_LIBS)
|
||||
|
||||
clientSDK: all
|
||||
|
||||
$(OBJDEST):
|
||||
$(MKDIR) $(OBJDEST)
|
||||
|
||||
$(BINDIR):
|
||||
$(MKDIR) $(BINDIR)
|
||||
|
||||
clean:
|
||||
$(RM) $(CLIENT_OBJS)
|
||||
$(RM) $(BINS)
|
||||
|
||||
#
|
||||
# Simple, local dependencies
|
||||
#
|
||||
LDAPTOOL_COMMON_DEPS = ldaptool.h Makefile
|
||||
$(LDAPTOOLCOMMON_OBJ): $(LDAPTOOL_COMMON_DEPS)
|
||||
$(LDAPDELETE_OBJ): $(LDAPTOOL_COMMON_DEPS)
|
||||
$(LDAPMODIFY_OBJ): $(LDAPTOOL_COMMON_DEPS) fileurl.h
|
||||
$(LDAPMODRDN_OBJ): $(LDAPTOOL_COMMON_DEPS)
|
||||
$(LDAPSEARCH_OBJ): $(LDAPTOOL_COMMON_DEPS) fileurl.h
|
||||
$(LDAPCMP_OBJ): $(LDAPTOOL_COMMON_DEPS)
|
||||
53
mozilla/directory/c-sdk/ldap/clients/tools/Options.txt
Normal file
53
mozilla/directory/c-sdk/ldap/clients/tools/Options.txt
Normal file
@@ -0,0 +1,53 @@
|
||||
Summary of options used by the LDAP tools
|
||||
|
||||
Updated 5-May-2000 by Mark Smith <mcs@netscape.com>
|
||||
|
||||
|
||||
Only single letter options in the sets [0-9], [A-Z], and [a-z] are
|
||||
listed.
|
||||
|
||||
The "raw" lists are taken from the calls to getopt() and
|
||||
ldaptool_process_args().
|
||||
|
||||
The "sorted" lists are just that -- sorted versions of the raw list.
|
||||
|
||||
The "all" lists include options from common.c as well as the tool-specific
|
||||
options.
|
||||
|
||||
The "avail" lists included options that are available for use.
|
||||
|
||||
|
||||
common.c (supported by all of the tools):
|
||||
raw: nvEMRHZ0d:D:f:h:I:K:N:O:P:p:Q:W:w:V:X:m:i:k:y:
|
||||
sorted: 0 DEHIKMNOPQRVWXZ dfhikmnpvwy
|
||||
avail: [2-9] CJY gj (not used by any of the tools)
|
||||
|
||||
ldapcmp.c:
|
||||
raw: Bb:l:s:z:
|
||||
sorted: B blsz
|
||||
all: 0 BDHIKMNOPQRVWXZ bdfhiklmnpsvwyz
|
||||
avail: [1-9] ACFGJLSTU acegjoqrtu
|
||||
|
||||
ldapdelete.c (deprecated)
|
||||
raw: c
|
||||
sorted: c
|
||||
all: 0 DHIKMNOPQRVWXZ cdfhikmnpvwy
|
||||
avail: [1-9] ABCFGJLSTUY abegjloqrstuxz
|
||||
|
||||
ldapmodify.c
|
||||
raw: aAbcFe:B:q
|
||||
sorted: ABF abceq
|
||||
all: 0 ABDFHIKMNOPQRVWXZ abcdefhikmnpqvwy
|
||||
avail: [1-9] CGJLSTUY gjlorstuxz
|
||||
|
||||
ldapmodrdn.c (deprecated)
|
||||
raw: cr
|
||||
sorted: cr
|
||||
all: 0 DHIKMNOPQRVWXZ cdfhikmnprvwy
|
||||
avail: [1-9] ABCFGJLSTUY abegjloqstuxz
|
||||
|
||||
ldapsearch.c
|
||||
raw: ABLTU1eotuxa:b:F:G:l:S:s:z:
|
||||
sorted: 1 ABFGLSTU abeostuxz
|
||||
all: 01 ABDFGHIKLMNOPQRSTUVWXZ abdefhikmnopstuvwxyz
|
||||
avail: [2-9] CJY cgjlqr
|
||||
129
mozilla/directory/c-sdk/ldap/clients/tools/argpin.c
Normal file
129
mozilla/directory/c-sdk/ldap/clients/tools/argpin.c
Normal file
@@ -0,0 +1,129 @@
|
||||
/******************************************************
|
||||
*
|
||||
* Copyright (c) 1996 Netscape Communications Corp.
|
||||
* This code is proprietary and is a trade secret of
|
||||
* Netscape Communications Corp.
|
||||
*
|
||||
* argpin.c - Returns pin for token specified in a
|
||||
* command line paramenter.
|
||||
*
|
||||
******************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "argpin.h"
|
||||
|
||||
struct SVRCOREArgPinObj
|
||||
{
|
||||
SVRCOREPinObj base;
|
||||
|
||||
char *tokenName;
|
||||
char *password;
|
||||
SVRCOREPinObj *alt;
|
||||
};
|
||||
static const struct SVRCOREPinMethods vtable;
|
||||
|
||||
/* XXXceb these are two hacks to fix a problem with the debug builds
|
||||
* of svrcore. With the optimizer turned off, there is a situation
|
||||
* in user.c, where these two functions need to be available for the
|
||||
* linker (they are imported, and no lib exports them, since they are
|
||||
* declared static on XP_UNIX platforms) The short term hack solution
|
||||
* is to define them here. Yeah, it is ugly but, it will need to be
|
||||
* here, until a new version of svrcore is done.
|
||||
*/
|
||||
|
||||
|
||||
void echoOff(int fd)
|
||||
{
|
||||
}
|
||||
|
||||
void echoOn(int fd)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
SVRCOREError
|
||||
SVRCORE_CreateArgPinObj(SVRCOREArgPinObj **out, const char * tokenName, const char *password, SVRCOREPinObj *pinObj)
|
||||
{
|
||||
SVRCOREError err = 0;
|
||||
SVRCOREArgPinObj *obj = 0;
|
||||
|
||||
do {
|
||||
obj = (SVRCOREArgPinObj*)malloc(sizeof (SVRCOREArgPinObj));
|
||||
if (!obj) { err = 1; break; }
|
||||
|
||||
obj->base.methods = &vtable;
|
||||
obj->tokenName=NULL;
|
||||
obj->password=NULL;
|
||||
obj->alt=pinObj;
|
||||
|
||||
if ( tokenName == NULL) {
|
||||
PK11SlotInfo *slot = PK11_GetInternalKeySlot();
|
||||
|
||||
obj->tokenName = strdup(PK11_GetTokenName(slot));
|
||||
PK11_FreeSlot(slot);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->tokenName = strdup(tokenName);
|
||||
}
|
||||
if (obj->tokenName == NULL) { err = 1; break; }
|
||||
|
||||
obj->password = strdup(password);
|
||||
if (obj->password == NULL) { err = 1; break; }
|
||||
} while(0);
|
||||
|
||||
if (err)
|
||||
{
|
||||
SVRCORE_DestroyArgPinObj(obj);
|
||||
obj = 0;
|
||||
}
|
||||
|
||||
*out = obj;
|
||||
return err;
|
||||
}
|
||||
|
||||
void
|
||||
SVRCORE_DestroyArgPinObj(SVRCOREArgPinObj *obj)
|
||||
{
|
||||
if (obj->tokenName) free(obj->tokenName);
|
||||
if (obj->password)
|
||||
{
|
||||
memset(obj->password, 0, strlen(obj->password));
|
||||
free(obj->password);
|
||||
}
|
||||
if (obj) free(obj);
|
||||
}
|
||||
|
||||
static void destroyObject(SVRCOREPinObj *obj)
|
||||
{
|
||||
SVRCORE_DestroyArgPinObj((SVRCOREArgPinObj*)obj);
|
||||
}
|
||||
|
||||
static char *getPin(SVRCOREPinObj *obj, const char *tokenName, PRBool retry)
|
||||
{
|
||||
SVRCOREArgPinObj *p = (SVRCOREArgPinObj*)obj;
|
||||
|
||||
if (tokenName == NULL) return NULL;
|
||||
|
||||
/* On first attempt, return the password if the token name
|
||||
* matches.
|
||||
*/
|
||||
if (!retry && strcmp(p->tokenName, tokenName) == 0)
|
||||
{
|
||||
return strdup(p->password);
|
||||
}
|
||||
|
||||
if (p->alt != NULL) return SVRCORE_GetPin(p->alt, tokenName, retry);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* VTable
|
||||
*/
|
||||
static const SVRCOREPinMethods vtable =
|
||||
{ 0, 0, destroyObject, getPin };
|
||||
|
||||
14
mozilla/directory/c-sdk/ldap/clients/tools/argpin.h
Normal file
14
mozilla/directory/c-sdk/ldap/clients/tools/argpin.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef __ARGPIN_H__
|
||||
#define __ARGPIN_H__
|
||||
|
||||
#include <svrcore.h>
|
||||
|
||||
typedef struct SVRCOREArgPinObj SVRCOREArgPinObj;
|
||||
|
||||
SVRCOREError
|
||||
SVRCORE_CreateArgPinObj(SVRCOREArgPinObj **out, const char * tokenName, const char *password, SVRCOREPinObj *pinObj);
|
||||
|
||||
void
|
||||
SVRCORE_DestroyArgPinObj(SVRCOREArgPinObj *obj);
|
||||
|
||||
#endif
|
||||
1760
mozilla/directory/c-sdk/ldap/clients/tools/common.c
Normal file
1760
mozilla/directory/c-sdk/ldap/clients/tools/common.c
Normal file
File diff suppressed because it is too large
Load Diff
536
mozilla/directory/c-sdk/ldap/clients/tools/convutf8.cpp
Normal file
536
mozilla/directory/c-sdk/ldap/clients/tools/convutf8.cpp
Normal file
@@ -0,0 +1,536 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef XP_WIN32
|
||||
#define VC_EXTRALEAN
|
||||
#include <afxwin.h>
|
||||
#include <winnls.h>
|
||||
#endif
|
||||
|
||||
extern char *ldaptool_charset;
|
||||
static int charsetset = 0;
|
||||
|
||||
extern "C" {
|
||||
char *ldaptool_convdir = NULL;
|
||||
char *ldaptool_local2UTF8( const char * );
|
||||
}
|
||||
|
||||
#ifndef XP_WIN32
|
||||
char * GetNormalizedLocaleName(void);
|
||||
|
||||
#include "unistring.h"
|
||||
#include "nlsenc.h"
|
||||
|
||||
extern NLS_StaticConverterRegistry _STATICLINK_NSJPN_;
|
||||
extern NLS_StaticConverterRegistry _STATICLINK_NSCCK_;
|
||||
extern NLS_StaticConverterRegistry _STATICLINK_NSSB_;
|
||||
|
||||
char *
|
||||
GetNormalizedLocaleName(void)
|
||||
{
|
||||
#ifdef _HPUX_SOURCE
|
||||
|
||||
int len;
|
||||
char *locale;
|
||||
|
||||
locale = setlocale(LC_CTYPE, "");
|
||||
if (locale && *locale) {
|
||||
len = strlen(locale);
|
||||
} else {
|
||||
locale = "C";
|
||||
len = 1;
|
||||
}
|
||||
|
||||
if ((!strncmp(locale, "/\x03:", 3)) &&
|
||||
(!strcmp(&locale[len - 2], ";/"))) {
|
||||
locale += 3;
|
||||
len -= 5;
|
||||
}
|
||||
|
||||
locale = strdup(locale);
|
||||
if (locale) {
|
||||
locale[len] = 0;
|
||||
}
|
||||
|
||||
return locale;
|
||||
|
||||
#else
|
||||
|
||||
char *locale;
|
||||
|
||||
locale = setlocale(LC_CTYPE, "");
|
||||
if (locale && *locale) {
|
||||
return strdup(locale);
|
||||
}
|
||||
|
||||
return strdup("C");
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(IRIX)
|
||||
const char *CHARCONVTABLE[] =
|
||||
{
|
||||
"! This table maps the host's locale names to LIBNLS charsets",
|
||||
"!",
|
||||
"C: ISO_8859-1:1987",
|
||||
"cs: ISO_8859-2:1987",
|
||||
"da: ISO_8859-1:1987",
|
||||
"de: ISO_8859-1:1987",
|
||||
"de_AT: ISO_8859-1:1987",
|
||||
"de_CH: ISO_8859-1:1987",
|
||||
"en: ISO_8859-1:1987",
|
||||
"en_AU: ISO_8859-1:1987",
|
||||
"en_CA: ISO_8859-1:1987",
|
||||
"en_TH: ISO_8859-1:1987",
|
||||
"en_US: ISO_8859-1:1987",
|
||||
"es: ISO_8859-1:1987",
|
||||
"fi: ISO_8859-1:1987",
|
||||
"fr: ISO_8859-1:1987",
|
||||
"fr_BE: ISO_8859-1:1987",
|
||||
"fr_CA: ISO_8859-1:1987",
|
||||
"fr_CH: ISO_8859-1:1987",
|
||||
"is: ISO_8859-1:1987",
|
||||
"it: ISO_8859-1:1987",
|
||||
"it_CH: ISO_8859-1:1987",
|
||||
"ja_JP.EUC: Extended_UNIX_Code_Packed_Format_for_Japanese",
|
||||
"ko_KR.euc: EUC-KR",
|
||||
"nl: ISO_8859-1:1987",
|
||||
"nl_BE: ISO_8859-1:1987",
|
||||
"no: ISO_8859-1:1987",
|
||||
"pl: ISO_8859-2:1987",
|
||||
"pt: ISO_8859-1:1987",
|
||||
"sh: ISO_8859-2:1987",
|
||||
"sk: ISO_8859-2:1987",
|
||||
"sv: ISO_8859-1:1987",
|
||||
"zh_CN.ugb: GB2312",
|
||||
"zh_TW.ucns: cns11643_1",
|
||||
NULL
|
||||
};
|
||||
#elif defined(SOLARIS)
|
||||
const char *CHARCONVTABLE[] =
|
||||
{
|
||||
"! This table maps the host's locale names to LIBNLS charsets",
|
||||
"!",
|
||||
"C: ISO_8859-1:1987",
|
||||
"ja: Extended_UNIX_Code_Packed_Format_for_Japanese",
|
||||
"ja_JP.EUC: Extended_UNIX_Code_Packed_Format_for_Japanese",
|
||||
"ja_JP.PCK: Shift_JIS",
|
||||
"en: ISO_8859-1:1987",
|
||||
"en_AU: ISO_8859-1:1987",
|
||||
"en_CA: ISO_8859-1:1987",
|
||||
"en_UK: ISO_8859-1:1987",
|
||||
"en_US: ISO_8859-1:1987",
|
||||
"es: ISO_8859-1:1987",
|
||||
"es_AR: ISO_8859-1:1987",
|
||||
"es_BO: ISO_8859-1:1987",
|
||||
"es_CL: ISO_8859-1:1987",
|
||||
"es_CO: ISO_8859-1:1987",
|
||||
"es_CR: ISO_8859-1:1987",
|
||||
"es_EC: ISO_8859-1:1987",
|
||||
"es_GT: ISO_8859-1:1987",
|
||||
"es_MX: ISO_8859-1:1987",
|
||||
"es_NI: ISO_8859-1:1987",
|
||||
"es_PA: ISO_8859-1:1987",
|
||||
"es_PE: ISO_8859-1:1987",
|
||||
"es_PY: ISO_8859-1:1987",
|
||||
"es_SV: ISO_8859-1:1987",
|
||||
"es_UY: ISO_8859-1:1987",
|
||||
"es_VE: ISO_8859-1:1987",
|
||||
"fr: ISO_8859-1:1987",
|
||||
"fr_BE: ISO_8859-1:1987",
|
||||
"fr_CA: ISO_8859-1:1987",
|
||||
"fr_CH: ISO_8859-1:1987",
|
||||
"de: ISO_8859-1:1987",
|
||||
"de_AT: ISO_8859-1:1987",
|
||||
"de_CH: ISO_8859-1:1987",
|
||||
"nl: ISO_8859-1:1987",
|
||||
"nl_BE: ISO_8859-1:1987",
|
||||
"it: ISO_8859-1:1987",
|
||||
"sv: ISO_8859-1:1987",
|
||||
"no: ISO_8859-1:1987",
|
||||
"da: ISO_8859-1:1987",
|
||||
"iso_8859_1: ISO_8859-1:1987",
|
||||
"japanese: Extended_UNIX_Code_Packed_Format_for_Japanese",
|
||||
"ko: EUC-KR",
|
||||
"zh: GB2312",
|
||||
"zh_TW: cns11643_1",
|
||||
NULL
|
||||
};
|
||||
#elif defined(OSF1)
|
||||
const char *CHARCONVTABLE[] =
|
||||
{
|
||||
"! This table maps the host's locale names to LIBNLS charsets",
|
||||
"!",
|
||||
"C: ISO_8859-1:1987",
|
||||
"cs_CZ.ISO8859-2: ISO_8859-2:1987",
|
||||
"cs_CZ: ISO_8859-2:1987",
|
||||
"da_DK.ISO8859-1: ISO_8859-1:1987",
|
||||
"de_CH.ISO8859-1: ISO_8859-1:1987",
|
||||
"de_DE.ISO8859-1: ISO_8859-1:1987",
|
||||
"en_GB.ISO8859-1: ISO_8859-1:1987",
|
||||
"en_US.ISO8859-1: ISO_8859-1:1987",
|
||||
"es_ES.ISO8859-1: ISO_8859-1:1987",
|
||||
"fi_FI.ISO8859-1: ISO_8859-1:1987",
|
||||
"fr_BE.ISO8859-1: ISO_8859-1:1987",
|
||||
"fr_CA.ISO8859-1: ISO_8859-1:1987",
|
||||
"fr_CH.ISO8859-1: ISO_8859-1:1987",
|
||||
"fr_FR.ISO8859-1: ISO_8859-1:1987",
|
||||
"hu_HU.ISO8859-2: ISO_8859-2:1987",
|
||||
"hu_HU: ISO_8859-2:1987",
|
||||
"is_IS.ISO8859-1: ISO_8859-1:1987",
|
||||
"it_IT.ISO8859-1: ISO_8859-1:1987",
|
||||
"ja_JP.SJIS: Shift_JIS",
|
||||
"ja_JP.eucJP: Extended_UNIX_Code_Packed_Format_for_Japanese",
|
||||
"ja_JP: Extended_UNIX_Code_Packed_Format_for_Japanese",
|
||||
"ko_KR.eucKR: EUC-KR",
|
||||
"ko_KR: EUC-KR",
|
||||
"nl_BE.ISO8859-1: ISO_8859-1:1987",
|
||||
"nl_NL.ISO8859-1: ISO_8859-1:1987",
|
||||
"no_NO.ISO8859-1: ISO_8859-1:1987",
|
||||
"pl_PL.ISO8859-2: ISO_8859-2:1987",
|
||||
"pl_PL: ISO_8859-2:1987",
|
||||
"pt_PT.ISO8859-1: ISO_8859-1:1987",
|
||||
"sk_SK.ISO8859-2: ISO_8859-2:1987",
|
||||
"sk_SK: ISO_8859-2:1987",
|
||||
"sv_SE.ISO8859-1: ISO_8859-1:1987",
|
||||
"zh_CN: GB2312",
|
||||
"zh_HK.big5: Big5",
|
||||
"zh_HK.eucTW: cns11643_1",
|
||||
"zh_TW.big5: Big5",
|
||||
"zh_TW.big5@chuyin: Big5",
|
||||
"zh_TW.big5@radical: Big5",
|
||||
"zh_TW.big5@stroke: Big5",
|
||||
"zh_TW.eucTW: cns11643_1",
|
||||
"zh_TW.eucTW@chuyin: cns11643_1",
|
||||
"zh_TW.eucTW@radical: cns11643_1",
|
||||
"zh_TW.eucTW@stroke: cns11643_1",
|
||||
"zh_TW: cns11643_1",
|
||||
NULL
|
||||
};
|
||||
#elif defined(HPUX)
|
||||
const char *CHARCONVTABLE[] =
|
||||
{
|
||||
"! This table maps the host's locale names to LIBNLS charsets",
|
||||
"!",
|
||||
"C: ISO_8859-1:1987",
|
||||
"ja_JP: Extended_UNIX_Code_Packed_Format_for_Japanese",
|
||||
"ja_JP.SJIS: Shift_JIS",
|
||||
"ja_JP.eucJP: Extended_UNIX_Code_Packed_Format_for_Japanese",
|
||||
"es_ES: ISO_8859-1:1987",
|
||||
"es_ES.iso88591: ISO_8859-1:1987",
|
||||
"sv_SE: ISO_8859-1:1987",
|
||||
"sv_SE.iso88591: ISO_8859-1:1987",
|
||||
"da_DK: ISO_8859-1:1987",
|
||||
"da_DK.iso88591: ISO_8859-1:1987",
|
||||
"nl_NL: ISO_8859-1:1987",
|
||||
"nl_NL.iso88591: ISO_8859-1:1987",
|
||||
"en: ISO_8859-1:1987",
|
||||
"en_GB: ISO_8859-1:1987",
|
||||
"en_GB.iso88591: ISO_8859-1:1987",
|
||||
"en_US: ISO_8859-1:1987",
|
||||
"en_US.iso88591: ISO_8859-1:1987",
|
||||
"fi_FI: ISO_8859-1:1987",
|
||||
"fi_FI.iso88591: ISO_8859-1:1987",
|
||||
"fr_CA: ISO_8859-1:1987",
|
||||
"fr_CA.iso88591: ISO_8859-1:1987",
|
||||
"fr_FR: ISO_8859-1:1987",
|
||||
"fr_FR.iso88591: ISO_8859-1:1987",
|
||||
"de_DE: ISO_8859-1:1987",
|
||||
"de_DE.iso88591: ISO_8859-1:1987",
|
||||
"is_IS: ISO_8859-1:1987",
|
||||
"is_IS.iso88591: ISO_8859-1:1987",
|
||||
"it_IT: ISO_8859-1:1987",
|
||||
"it_IT.iso88591: ISO_8859-1:1987",
|
||||
"no_NO: ISO_8859-1:1987",
|
||||
"no_NO.iso88591: ISO_8859-1:1987",
|
||||
"pt_PT: ISO_8859-1:1987",
|
||||
"pt_PT.iso88591: ISO_8859-1:1987",
|
||||
"hu_HU: ISO_8859-2:1987",
|
||||
"hu_HU.iso88592: ISO_8859-2:1987",
|
||||
"cs_CZ: ISO_8859-2:1987",
|
||||
"cs_CZ.iso88592: ISO_8859-2:1987",
|
||||
"pl_PL: ISO_8859-2:1987",
|
||||
"pl_PL.iso88592: ISO_8859-2:1987",
|
||||
"ro_RO: ISO_8859-2:1987",
|
||||
"ro_RO.iso88592: ISO_8859-2:1987",
|
||||
"hr_HR: ISO_8859-2:1987",
|
||||
"hr_HR.iso88592: ISO_8859-2:1987",
|
||||
"sk_SK: ISO_8859-2:1987",
|
||||
"sk_SK.iso88592: ISO_8859-2:1987",
|
||||
"sl_SI: ISO_8859-2:1987",
|
||||
"sl_SI.iso88592: ISO_8859-2:1987",
|
||||
"american.iso88591: ISO_8859-1:1987",
|
||||
"bulgarian: ISO_8859-2:1987",
|
||||
"c-french.iso88591: ISO_8859-1:1987",
|
||||
"chinese-s: GB2312",
|
||||
"chinese-t.big5: Big5",
|
||||
"czech: ISO_8859-2:1987",
|
||||
"danish.iso88591: ISO_8859-1:1987",
|
||||
"dutch.iso88591: ISO_8859-1:1987",
|
||||
"english.iso88591: ISO_8859-1:1987",
|
||||
"finnish.iso88591: ISO_8859-1:1987",
|
||||
"french.iso88591: ISO_8859-1:1987",
|
||||
"german.iso88591: ISO_8859-1:1987",
|
||||
"hungarian: ISO_8859-2:1987",
|
||||
"icelandic.iso88591: ISO_8859-1:1987",
|
||||
"italian.iso88591: ISO_8859-1:1987",
|
||||
"japanese.euc: Extended_UNIX_Code_Packed_Format_for_Japanese",
|
||||
"japanese: Shift_JIS",
|
||||
"katakana: Shift_JIS",
|
||||
"korean: EUC-KR",
|
||||
"norwegian.iso88591: ISO_8859-1:1987",
|
||||
"polish: ISO_8859-2:1987",
|
||||
"portuguese.iso88591: ISO_8859-1:1987",
|
||||
"rumanian: ISO_8859-2:1987",
|
||||
"serbocroatian: ISO_8859-2:1987",
|
||||
"slovene: ISO_8859-2:1987",
|
||||
"spanish.iso88591: ISO_8859-1:1987",
|
||||
"swedish.iso88591: ISO_8859-1:1987",
|
||||
NULL
|
||||
};
|
||||
#elif defined(AIX)
|
||||
const char *CHARCONVTABLE[] =
|
||||
{
|
||||
"! This table maps the host's locale names to LIBNLS charsets",
|
||||
"!",
|
||||
"C: ISO_8859-1:1987",
|
||||
"En_JP.IBM-932: Shift_JIS",
|
||||
"En_JP: Shift_JIS",
|
||||
"Ja_JP.IBM-932: Shift_JIS",
|
||||
"Ja_JP: Shift_JIS",
|
||||
"da_DK.ISO8859-1: ISO_8859-1:1987",
|
||||
"da_DK: ISO_8859-1:1987",
|
||||
"de_CH.ISO8859-1: ISO_8859-1:1987",
|
||||
"de_CH: ISO_8859-1:1987",
|
||||
"de_DE.ISO8859-1: ISO_8859-1:1987",
|
||||
"de_DE: ISO_8859-1:1987",
|
||||
"en_GB.ISO8859-1: ISO_8859-1:1987",
|
||||
"en_GB: ISO_8859-1:1987",
|
||||
"en_JP.IBM-eucJP: Extended_UNIX_Code_Packed_Format_for_Japanese",
|
||||
"en_JP: Extended_UNIX_Code_Packed_Format_for_Japanese",
|
||||
"en_KR.IBM-eucKR: EUC-KR",
|
||||
"en_KR: EUC-KR",
|
||||
"en_TW.IBM-eucTW: cns11643_1",
|
||||
"en_TW: cns11643_1",
|
||||
"en_US.ISO8859-1: ISO_8859-1:1987",
|
||||
"en_US: ISO_8859-1:1987",
|
||||
"es_ES.ISO8859-1: ISO_8859-1:1987",
|
||||
"es_ES: ISO_8859-1:1987",
|
||||
"fi_FI.ISO8859-1: ISO_8859-1:1987",
|
||||
"fi_FI: ISO_8859-1:1987",
|
||||
"fr_BE.ISO8859-1: ISO_8859-1:1987",
|
||||
"fr_BE: ISO_8859-1:1987",
|
||||
"fr_CA.ISO8859-1: ISO_8859-1:1987",
|
||||
"fr_CA: ISO_8859-1:1987",
|
||||
"fr_CH.ISO8859-1: ISO_8859-1:1987",
|
||||
"fr_CH: ISO_8859-1:1987",
|
||||
"fr_FR.ISO8859-1: ISO_8859-1:1987",
|
||||
"fr_FR: ISO_8859-1:1987",
|
||||
"is_IS.ISO8859-1: ISO_8859-1:1987",
|
||||
"is_IS: ISO_8859-1:1987",
|
||||
"it_IT.ISO8859-1: ISO_8859-1:1987",
|
||||
"it_IT: ISO_8859-1:1987",
|
||||
"ja_JP.IBM-eucJP: Extended_UNIX_Code_Packed_Format_for_Japanese",
|
||||
"ja_JP: Extended_UNIX_Code_Packed_Format_for_Japanese",
|
||||
"ko_KR.IBM-eucKR: EUC-KR",
|
||||
"ko_KR: EUC-KR",
|
||||
"nl_BE.ISO8859-1: ISO_8859-1:1987",
|
||||
"nl_BE: ISO_8859-1:1987",
|
||||
"nl_NL.ISO8859-1: ISO_8859-1:1987",
|
||||
"nl_NL: ISO_8859-1:1987",
|
||||
"no_NO.ISO8859-1: ISO_8859-1:1987",
|
||||
"no_NO: ISO_8859-1:1987",
|
||||
"pt_PT.ISO8859-1: ISO_8859-1:1987",
|
||||
"pt_PT: ISO_8859-1:1987",
|
||||
"sv_SE.ISO8859-1: ISO_8859-1:1987",
|
||||
"sv_SE: ISO_8859-1:1987",
|
||||
"zh_TW.IBM-eucTW: cns11643_1",
|
||||
"zh_TW: cns11643_1",
|
||||
NULL
|
||||
};
|
||||
#else // sunos by default
|
||||
const char *CHARCONVTABLE[] =
|
||||
{
|
||||
"! This table maps the host's locale names to LIBNLS charsets",
|
||||
"!",
|
||||
"C: ISO_8859-1:1987",
|
||||
"de: ISO_8859-1:1987",
|
||||
"en_US: ISO_8859-1:1987",
|
||||
"es: ISO_8859-1:1987",
|
||||
"fr: ISO_8859-1:1987",
|
||||
"iso_8859_1: ISO_8859-1:1987",
|
||||
"it: ISO_8859-1:1987",
|
||||
"ja: Extended_UNIX_Code_Packed_Format_for_Japanese",
|
||||
"ja_JP.EUC: Extended_UNIX_Code_Packed_Format_for_Japanese",
|
||||
"japanese: Extended_UNIX_Code_Packed_Format_for_Japanese",
|
||||
"ko: EUC-KR",
|
||||
"sv: ISO_8859-1:1987",
|
||||
"zh: GB2312",
|
||||
"zh_TW: cns11643_1",
|
||||
NULL
|
||||
};
|
||||
#endif
|
||||
|
||||
#define BSZ 256
|
||||
|
||||
char *
|
||||
GetCharsetFromLocale(char *locale)
|
||||
{
|
||||
char *tmpcharset = NULL;
|
||||
char buf[BSZ];
|
||||
char *p;
|
||||
const char *line;
|
||||
int i=0;
|
||||
|
||||
line = CHARCONVTABLE[i];
|
||||
while (line != NULL)
|
||||
{
|
||||
if (*line == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
strcpy(buf, line);
|
||||
line = CHARCONVTABLE[++i];
|
||||
|
||||
if (strlen(buf) == 0 || buf[0] == '!')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
p = strchr(buf, ':');
|
||||
if (p == NULL)
|
||||
{
|
||||
tmpcharset = NULL;
|
||||
break;
|
||||
}
|
||||
*p = 0;
|
||||
if (strcmp(buf, locale) == 0) {
|
||||
while (*++p == ' ' || *p == '\t')
|
||||
;
|
||||
if (isalpha(*p)) {
|
||||
tmpcharset = strdup(p);
|
||||
} else
|
||||
tmpcharset = NULL;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
return tmpcharset;
|
||||
}
|
||||
|
||||
#endif /* Not defined XP_WIN32 */
|
||||
|
||||
#ifdef XP_WIN32
|
||||
char *_convertor(const char *instr, int bFromUTF8)
|
||||
{
|
||||
char *outstr = NULL;
|
||||
int inlen, wclen, outlen;
|
||||
LPWSTR wcstr;
|
||||
|
||||
if (instr == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((inlen = strlen(instr)) <= 0)
|
||||
return NULL;
|
||||
|
||||
/* output never becomes longer than input,
|
||||
** thus we don't have to ask for the length
|
||||
*/
|
||||
wcstr = (LPWSTR) malloc( sizeof( WCHAR ) * (inlen+1) );
|
||||
if (!wcstr)
|
||||
return NULL;
|
||||
|
||||
wclen = MultiByteToWideChar(bFromUTF8 ? CP_UTF8 : CP_ACP, 0, instr,
|
||||
inlen, wcstr, inlen);
|
||||
outlen = WideCharToMultiByte(bFromUTF8 ? CP_ACP : CP_UTF8, 0, wcstr,
|
||||
wclen, NULL, 0, NULL, NULL);
|
||||
|
||||
if (outlen > 0) {
|
||||
outstr = (char *) malloc(outlen + 2);
|
||||
outlen = WideCharToMultiByte(bFromUTF8 ? CP_ACP : CP_UTF8, 0, wcstr,
|
||||
wclen, outstr, outlen, NULL, NULL);
|
||||
if (outlen > 0)
|
||||
*(outstr+outlen) = _T('\0');
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
free( wcstr );
|
||||
return outstr;
|
||||
}
|
||||
#endif
|
||||
|
||||
char *
|
||||
ldaptool_local2UTF8( const char *src )
|
||||
{
|
||||
char *utf8;
|
||||
#ifndef XP_WIN32
|
||||
char *locale, *newcharset;
|
||||
size_t outLen, resultLen;
|
||||
NLS_ErrorCode err;
|
||||
|
||||
if (src == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else if (*src == 0)
|
||||
{
|
||||
utf8 = strdup(src);
|
||||
return utf8;
|
||||
}
|
||||
|
||||
if( (ldaptool_charset != NULL) && (!strcmp( ldaptool_charset, "" ))
|
||||
&& (!charsetset) )
|
||||
{
|
||||
locale = GetNormalizedLocaleName();
|
||||
ldaptool_charset = GetCharsetFromLocale(locale);
|
||||
free( locale );
|
||||
charsetset = 1;
|
||||
}
|
||||
else
|
||||
if( (ldaptool_charset != NULL) && strcmp( ldaptool_charset, "" )
|
||||
&& (!charsetset) )
|
||||
{
|
||||
newcharset = GetCharsetFromLocale( ldaptool_charset );
|
||||
free( ldaptool_charset );
|
||||
ldaptool_charset = newcharset;
|
||||
charsetset = 1;
|
||||
}
|
||||
|
||||
if (ldaptool_charset == NULL) {
|
||||
return strdup(src);
|
||||
}
|
||||
|
||||
if (NLS_EncInitialize(NULL, ldaptool_convdir) != NLS_SUCCESS ||
|
||||
NLS_RegisterStaticLibrary(_STATICLINK_NSJPN_) != NLS_SUCCESS ||
|
||||
NLS_RegisterStaticLibrary(_STATICLINK_NSCCK_) != NLS_SUCCESS ||
|
||||
NLS_RegisterStaticLibrary(_STATICLINK_NSSB_) != NLS_SUCCESS) {
|
||||
return strdup(src);
|
||||
}
|
||||
|
||||
outLen = NLS_GetResultBufferSize( (byte *) src,
|
||||
strlen( src ) * sizeof(char),
|
||||
ldaptool_charset,
|
||||
NLS_ENCODING_UTF_8 );
|
||||
|
||||
utf8 = (char *) malloc( outLen/sizeof(UniChar) );
|
||||
if( utf8 == NULL )
|
||||
return strdup(src);
|
||||
|
||||
err = NLS_ConvertBuffer( ldaptool_charset,
|
||||
NLS_ENCODING_UTF_8,
|
||||
(byte*)src,
|
||||
strlen(src) * sizeof(char),
|
||||
(byte*)utf8,
|
||||
outLen,
|
||||
&resultLen );
|
||||
|
||||
NLS_EncTerminate();
|
||||
|
||||
#else
|
||||
utf8 = _convertor(src, FALSE);
|
||||
if( utf8 == NULL )
|
||||
utf8 = strdup(src);
|
||||
#endif
|
||||
|
||||
return utf8;
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
# LDIF examples, taken from the specification which was found at:
|
||||
# http://www.ietf.org/internet-drafts/draft-good-ldap-ldif-03.txt
|
||||
|
||||
# Example 1: An simple LDAP file with two entries
|
||||
version: 1
|
||||
dn: cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
cn: Barbara Jensen
|
||||
cn: Barbara J Jensen
|
||||
cn: Babs Jensen
|
||||
sn: Jensen
|
||||
uid: bjensen
|
||||
telephonenumber: +1 408 555 1212
|
||||
description: A big sailing fan.
|
||||
|
||||
dn: cn=Bjorn Jensen, ou=Accounting, dc=airius, dc=com
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
cn: Bjorn Jensen
|
||||
sn: Jensen
|
||||
telephonenumber: +1 408 555 1212
|
||||
|
||||
# Example 2: A file containing an entry with a folded attribute value
|
||||
version: 1
|
||||
dn:cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com
|
||||
objectclass:top
|
||||
objectclass:person
|
||||
objectclass:organizationalPerson
|
||||
cn:Barbara Jensen
|
||||
cn:Barbara J Jensen
|
||||
cn:Babs Jensen
|
||||
sn:Jensen
|
||||
uid:bjensen
|
||||
telephonenumber:+1 408 555 1212
|
||||
description:Babs is a big sailing fan, and travels extensively in search of
|
||||
perfect sailing conditions.
|
||||
title:Product Manager, Rod and Reel Division
|
||||
|
||||
# Example 3: A file containing a base-64-encoded value
|
||||
version: 1
|
||||
dn: cn=Gern Jensen, ou=Product Testing, dc=airius, dc=com
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
cn: Gern Jensen
|
||||
cn: Gern O Jensen
|
||||
sn: Jensen
|
||||
uid: gernj
|
||||
telephonenumber: +1 408 555 1212
|
||||
description:: V2hhdCBhIGNhcmVmdWwgcmVhZGVyIHlvdSBhcmUhICBUaGlzIHZhbHVlIGlzIGJ
|
||||
hc2UtNjQtZW5jb2RlZCBiZWNhdXNlIGl0IGhhcyBhIGNvbnRyb2wgY2hhcmFjdGVyIGluIGl0ICh
|
||||
hIENSKS4NICBCeSB0aGUgd2F5LCB5b3Ugc2hvdWxkIHJlYWxseSBnZXQgb3V0IG1vcmUu
|
||||
|
||||
# Example 4: A file containing an entries with UTF-8-encoded attribute
|
||||
# values, including language tags. Comments indicate the contents
|
||||
# of UTF-8-encoded attributes and distinguished names.
|
||||
version: 1
|
||||
dn:: b3U95Za25qWt6YOoLG89QWlyaXVz
|
||||
# dn:: ou=<JapaneseOU>,o=Airius
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou:: 5Za25qWt6YOo
|
||||
# ou:: <JapaneseOU>
|
||||
ou;lang-ja:: 5Za25qWt6YOo
|
||||
# ou;lang-ja:: <JapaneseOU>
|
||||
ou;lang-ja;phonetic:: 44GI44GE44GO44KH44GG44G2
|
||||
# ou;lang-ja:: <JapaneseOU_in_phonetic_representation>
|
||||
ou;lang-en: Sales
|
||||
description: Japanese office
|
||||
|
||||
dn:: dWlkPXJvZ2FzYXdhcmEsb3U95Za25qWt6YOoLG89QWlyaXVz
|
||||
# dn:: uid=<uid>,ou=<JapaneseOU>,o=Airius
|
||||
userpassword: {SHA}O3HSv1MusyL4kTjP+HKI5uxuNoM=
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
objectclass: inetOrgPerson
|
||||
uid: rogasawara
|
||||
mail: rogasawara@airius.co.jp
|
||||
givenname;lang-ja:: 44Ot44OJ44OL44O8
|
||||
# givenname;lang-ja:: <JapaneseGivenname>
|
||||
sn;lang-ja:: 5bCP56yg5Y6f
|
||||
# sn;lang-ja:: <JapaneseSn>
|
||||
cn;lang-ja:: 5bCP56yg5Y6fIOODreODieODi+ODvA==
|
||||
# cn;lang-ja:: <JapaneseCn>
|
||||
title;lang-ja:: 5Za25qWt6YOoIOmDqOmVtw==
|
||||
# title;lang-ja:: <JapaneseTitle>
|
||||
preferredlanguage: ja
|
||||
givenname:: 44Ot44OJ44OL44O8
|
||||
# givenname:: <JapaneseGivenname>
|
||||
sn:: 5bCP56yg5Y6f
|
||||
# sn:: <JapaneseSn>
|
||||
cn:: 5bCP56yg5Y6fIOODreODieODi+ODvA==
|
||||
# cn:: <JapaneseCn>
|
||||
title:: 5Za25qWt6YOoIOmDqOmVtw==
|
||||
# title:: <JapaneseTitle>
|
||||
givenname;lang-ja;phonetic:: 44KN44Gp44Gr44O8
|
||||
# givenname;lang-ja;phonetic:: <JapaneseGivenname_in_phonetic_representation_kana>
|
||||
sn;lang-ja;phonetic:: 44GK44GM44GV44KP44KJ
|
||||
# sn;lang-ja;phonetic:: <JapaneseSn_in_phonetic_representation_kana>
|
||||
cn;lang-ja;phonetic:: 44GK44GM44GV44KP44KJIOOCjeOBqeOBq+ODvA==
|
||||
# cn;lang-ja;phonetic:: <JapaneseCn_in_phonetic_representation_kana>
|
||||
title;lang-ja;phonetic:: 44GI44GE44GO44KH44GG44G2IOOBtuOBoeOCh+OBhg==
|
||||
# title;lang-ja;phonetic:: <JapaneseTitle_in_phonetic_representation_kana>
|
||||
givenname;lang-en: Rodney
|
||||
sn;lang-en: Ogasawara
|
||||
cn;lang-en: Rodney Ogasawara
|
||||
title;lang-en: Sales, Director
|
||||
|
||||
# Example 5: A file containing a reference to an external file
|
||||
version: 1
|
||||
dn: cn=Horatio Jensen, ou=Product Testing, dc=airius, dc=com
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
cn: Horatio Jensen
|
||||
cn: Horatio N Jensen
|
||||
sn: Jensen
|
||||
uid: hjensen
|
||||
telephonenumber: +1 408 555 1212
|
||||
# XXXmcs: In the spec, the following line reads:
|
||||
# jpegphoto:< file:///usr/local/directory/photos/hjensen.jpg
|
||||
# I changed the file URL to point to a more generic directory.
|
||||
jpegphoto:< file:///tmp/hjensen.jpg
|
||||
|
||||
# Example 6: A file containing a series of change records and comments
|
||||
version: 1
|
||||
# Add a new entry
|
||||
dn: cn=Fiona Jensen, ou=Marketing, dc=airius, dc=com
|
||||
changetype: add
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
cn: Fiona Jensen
|
||||
sn: Jensen
|
||||
uid: fiona
|
||||
telephonenumber: +1 408 555 1212
|
||||
# XXXmcs: In the spec, the following line reads:
|
||||
# jpegphoto:< file:///usr/local/directory/photos/fiona.jpg
|
||||
# I changed the file URL to point to a more generic directory.
|
||||
jpegphoto:< file:///tmp/fiona.jpg
|
||||
|
||||
# Delete an existing entry
|
||||
dn: cn=Robert Jensen, ou=Marketing, dc=airius, dc=com
|
||||
changetype: delete
|
||||
|
||||
# Modify an entry's relative distinguished name
|
||||
dn: cn=Paul Jensen, ou=Product Development, dc=airius, dc=com
|
||||
changetype: modrdn
|
||||
newrdn: cn=Paula Jensen
|
||||
deleteoldrdn: 1
|
||||
|
||||
# Rename an entry and move all of its children to a new location in
|
||||
# the directory tree (only implemented by LDAPv3 servers).
|
||||
dn: ou=PD Accountants, ou=Product Development, dc=airius, dc=com
|
||||
changetype: modrdn
|
||||
newrdn: ou=Product Development Accountants
|
||||
deleteoldrdn: 0
|
||||
newsuperior: ou=Accounting, dc=airius, dc=com
|
||||
|
||||
# Modify an entry: add an additional value to the postaladdress attribute,
|
||||
# completely delete the description attribute, replace the telephonenumber
|
||||
# attribute with two values, and delete a specific value from the
|
||||
# facsimiletelephonenumber attribute
|
||||
dn: cn=Paula Jensen, ou=Product Development, dc=airius, dc=com
|
||||
changetype: modify
|
||||
add: postaladdress
|
||||
postaladdress: 123 Anystreet $ Sunnyvale, CA $ 94086
|
||||
-
|
||||
delete: description
|
||||
-
|
||||
replace: telephonenumber
|
||||
telephonenumber: +1 408 555 1234
|
||||
telephonenumber: +1 408 555 5678
|
||||
-
|
||||
delete: facsimiletelephonenumber
|
||||
facsimiletelephonenumber: +1 408 555 9876
|
||||
-
|
||||
280
mozilla/directory/c-sdk/ldap/clients/tools/fileurl.c
Normal file
280
mozilla/directory/c-sdk/ldap/clients/tools/fileurl.c
Normal file
@@ -0,0 +1,280 @@
|
||||
/*
|
||||
* LDAP tools fileurl.c -- functions for handling file URLs.
|
||||
* Used by ldapmodify.
|
||||
*/
|
||||
|
||||
#include "ldaptool.h"
|
||||
#include "fileurl.h"
|
||||
#include <ctype.h> /* for isalpha() */
|
||||
|
||||
static int str_starts_with( char *s, char *prefix );
|
||||
static void hex_unescape( char *s );
|
||||
static int unhex( char c );
|
||||
static void strcpy_escaped_and_convert( char *s1, char *s2 );
|
||||
|
||||
/*
|
||||
* Convert a file URL to a local path.
|
||||
*
|
||||
* If successful, LDAPTOOL_FILEURL_SUCCESS is returned and *localpathp is
|
||||
* set point to an allocated string. If not, an different LDAPTOOL_FILEURL_
|
||||
* error code is returned.
|
||||
*
|
||||
* See RFCs 1738 and 2396 for a specification for file URLs... but
|
||||
* Netscape Navigator seems to be a bit more lenient in what it will
|
||||
* accept, especially on Windows).
|
||||
*
|
||||
* This function parses file URLs of these three forms:
|
||||
*
|
||||
* file:///path
|
||||
* file:/path
|
||||
* file://localhost/path
|
||||
* file://host/path (rejected with a ...NONLOCAL error)
|
||||
*
|
||||
* On Windows, we convert leading drive letters of the form C| to C:
|
||||
* and if a drive letter is present we strip off the slash that precedes
|
||||
* path. Otherwise, the leading slash is returned.
|
||||
*
|
||||
*/
|
||||
int
|
||||
ldaptool_fileurl2path( char *fileurl, char **localpathp )
|
||||
{
|
||||
char *path;
|
||||
|
||||
/*
|
||||
* Make sure this is a file URL we can handle.
|
||||
*/
|
||||
if ( !str_starts_with( fileurl, "file:" )) {
|
||||
return( LDAPTOOL_FILEURL_NOTAFILEURL );
|
||||
}
|
||||
|
||||
path = fileurl + 5; /* skip past "file:" scheme prefix */
|
||||
|
||||
if ( *path != '/' ) {
|
||||
return( LDAPTOOL_FILEURL_MISSINGPATH );
|
||||
}
|
||||
|
||||
++path; /* skip past '/' at end of "file:/" */
|
||||
|
||||
if ( *path == '/' ) {
|
||||
++path; /* remainder is now host/path or /path */
|
||||
if ( *path != '/' ) {
|
||||
/*
|
||||
* Make sure it is for the local host.
|
||||
*/
|
||||
if ( str_starts_with( path, "localhost/" )) {
|
||||
path += 9;
|
||||
} else {
|
||||
return( LDAPTOOL_FILEURL_NONLOCAL );
|
||||
}
|
||||
}
|
||||
} else { /* URL is of the form file:/path */
|
||||
--path;
|
||||
}
|
||||
|
||||
/*
|
||||
* The remainder is now of the form /path. On Windows, skip past the
|
||||
* leading slash if a drive letter is present.
|
||||
*/
|
||||
#ifdef _WINDOWS
|
||||
if ( isalpha( path[1] ) && ( path[2] == '|' || path[2] == ':' )) {
|
||||
++path;
|
||||
}
|
||||
#endif /* _WINDOWS */
|
||||
|
||||
/*
|
||||
* Duplicate the path so we can safely alter it.
|
||||
* Unescape any %HH sequences.
|
||||
*/
|
||||
if (( path = strdup( path )) == NULL ) {
|
||||
return( LDAPTOOL_FILEURL_NOMEMORY );
|
||||
}
|
||||
hex_unescape( path );
|
||||
|
||||
#ifdef _WINDOWS
|
||||
/*
|
||||
* Convert forward slashes to backslashes for Windows. Also,
|
||||
* if we see a drive letter / vertical bar combination (e.g., c|)
|
||||
* at the beginning of the path, replace the '|' with a ':'.
|
||||
*/
|
||||
{
|
||||
char *p;
|
||||
|
||||
for ( p = path; *p != '\0'; ++p ) {
|
||||
if ( *p == '/' ) {
|
||||
*p = '\\';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isalpha( path[0] ) && path[1] == '|' ) {
|
||||
path[1] = ':';
|
||||
}
|
||||
#endif /* _WINDOWS */
|
||||
|
||||
*localpathp = path;
|
||||
return( LDAPTOOL_FILEURL_SUCCESS );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Convert a local path to a file URL.
|
||||
*
|
||||
* If successful, LDAPTOOL_FILEURL_SUCCESS is returned and *urlp is
|
||||
* set point to an allocated string. If not, an different LDAPTOOL_FILEURL_
|
||||
* error code is returned. At present, the only possible error is
|
||||
* LDAPTOOL_FILEURL_NOMEMORY.
|
||||
*
|
||||
* This function produces file URLs of the form file:path.
|
||||
*
|
||||
* On Windows, we convert leading drive letters to C|.
|
||||
*
|
||||
*/
|
||||
int
|
||||
ldaptool_path2fileurl( char *path, char **urlp )
|
||||
{
|
||||
char *p, *url, *prefix ="file:";
|
||||
|
||||
if ( NULL == path ) {
|
||||
path = "/";
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate space for the URL, taking into account that path may
|
||||
* expand during the hex escaping process.
|
||||
*/
|
||||
if (( url = malloc( strlen( prefix ) + 3 * strlen( path ) + 1 )) == NULL ) {
|
||||
return( LDAPTOOL_FILEURL_NOMEMORY );
|
||||
}
|
||||
|
||||
strcpy( url, prefix );
|
||||
p = url + strlen( prefix );
|
||||
|
||||
#ifdef _WINDOWS
|
||||
/*
|
||||
* On Windows, convert leading drive letters (e.g., C:) to the correct URL
|
||||
* syntax (e.g., C|).
|
||||
*/
|
||||
if ( isalpha( path[0] ) && path[1] == ':' ) {
|
||||
*p++ = path[0];
|
||||
*p++ = '|';
|
||||
path += 2;
|
||||
*p = '\0';
|
||||
}
|
||||
#endif /* _WINDOWS */
|
||||
|
||||
/*
|
||||
* Append the path, encoding any URL-special characters using the %HH
|
||||
* convention.
|
||||
* On Windows, convert backwards slashes in the path to forward ones.
|
||||
*/
|
||||
strcpy_escaped_and_convert( p, path );
|
||||
|
||||
*urlp = url;
|
||||
return( LDAPTOOL_FILEURL_SUCCESS );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Return a non-zero value if the string s begins with prefix and zero if not.
|
||||
*/
|
||||
static int
|
||||
str_starts_with( char *s, char *prefix )
|
||||
{
|
||||
size_t prefix_len;
|
||||
|
||||
if ( s == NULL || prefix == NULL ) {
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
prefix_len = strlen( prefix );
|
||||
if ( strlen( s ) < prefix_len ) {
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
return( strncmp( s, prefix, prefix_len ) == 0 );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Remove URL hex escapes from s... done in place. The basic concept for
|
||||
* this routine is borrowed from the WWW library HTUnEscape() routine.
|
||||
*
|
||||
* A similar function called nsldapi_hex_unescape can be found in
|
||||
* ../../libraries/libldap/unescape.c
|
||||
*/
|
||||
static void
|
||||
hex_unescape( char *s )
|
||||
{
|
||||
char *p;
|
||||
|
||||
for ( p = s; *s != '\0'; ++s ) {
|
||||
if ( *s == '%' ) {
|
||||
if ( *++s != '\0' ) {
|
||||
*p = unhex( *s ) << 4;
|
||||
}
|
||||
if ( *++s != '\0' ) {
|
||||
*p++ += unhex( *s );
|
||||
}
|
||||
} else {
|
||||
*p++ = *s;
|
||||
}
|
||||
}
|
||||
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Return the integer equivalent of one hex digit (in c).
|
||||
*
|
||||
* A similar function can be found in ../../libraries/libldap/unescape.c
|
||||
*/
|
||||
static int
|
||||
unhex( char c )
|
||||
{
|
||||
return( c >= '0' && c <= '9' ? c - '0'
|
||||
: c >= 'A' && c <= 'F' ? c - 'A' + 10
|
||||
: c - 'a' + 10 );
|
||||
}
|
||||
|
||||
|
||||
#define HREF_CHAR_ACCEPTABLE( c ) (( c >= '-' && c <= '9' ) || \
|
||||
( c >= '@' && c <= 'Z' ) || \
|
||||
( c == '_' ) || \
|
||||
( c >= 'a' && c <= 'z' ))
|
||||
|
||||
/*
|
||||
* Like strcat(), except if any URL-special characters are found in s2
|
||||
* they are escaped using the %HH convention and backslash characters are
|
||||
* converted to forward slashes on Windows.
|
||||
*
|
||||
* Maximum space needed in s1 is 3 * strlen( s2 ) + 1.
|
||||
*
|
||||
* A similar function that does not convert the slashes called
|
||||
* strcat_escaped() can be found in ../../libraries/libldap/tmplout.c
|
||||
*/
|
||||
static void
|
||||
strcpy_escaped_and_convert( char *s1, char *s2 )
|
||||
{
|
||||
char *p, *q;
|
||||
char *hexdig = "0123456789ABCDEF";
|
||||
|
||||
p = s1 + strlen( s1 );
|
||||
for ( q = s2; *q != '\0'; ++q ) {
|
||||
#ifdef _WINDOWS
|
||||
if ( *q == '\\' ) {
|
||||
*p++ = '/';
|
||||
} else
|
||||
#endif /* _WINDOWS */
|
||||
|
||||
if ( HREF_CHAR_ACCEPTABLE( *q )) {
|
||||
*p++ = *q;
|
||||
} else {
|
||||
*p++ = '%';
|
||||
*p++ = hexdig[ 0x0F & ((*(unsigned char*)q) >> 4) ];
|
||||
*p++ = hexdig[ 0x0F & *q ];
|
||||
}
|
||||
}
|
||||
|
||||
*p = '\0';
|
||||
}
|
||||
35
mozilla/directory/c-sdk/ldap/clients/tools/fileurl.h
Normal file
35
mozilla/directory/c-sdk/ldap/clients/tools/fileurl.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* LDAP tools fileurl.h -- defines for file URL functions.
|
||||
* Used by ldapmodify.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ldaptool_fileurl2path() convert a file URL to a local path.
|
||||
*
|
||||
* If successful, LDAPTOOL_FILEURL_SUCCESS is returned and *localpathp is
|
||||
* set point to an allocated string. If not, an differnet LDAPTOOL_FILEURL_
|
||||
* error code is returned.
|
||||
*/
|
||||
int ldaptool_fileurl2path( char *fileurl, char **localpathp );
|
||||
|
||||
|
||||
/*
|
||||
* Convert a local path to a file URL.
|
||||
*
|
||||
* If successful, LDAPTOOL_FILEURL_SUCCESS is returned and *urlp is
|
||||
* set point to an allocated string. If not, an different LDAPTOOL_FILEURL_
|
||||
* error code is returned. At present, the only possible error is
|
||||
* LDAPTOOL_FILEURL_NOMEMORY.
|
||||
*
|
||||
*/
|
||||
int ldaptool_path2fileurl( char *path, char **urlp );
|
||||
|
||||
|
||||
/*
|
||||
* Possible return codes for ldaptool_fileurl2path and ldaptool_path2fileurl.
|
||||
*/
|
||||
#define LDAPTOOL_FILEURL_SUCCESS 0
|
||||
#define LDAPTOOL_FILEURL_NOTAFILEURL 1
|
||||
#define LDAPTOOL_FILEURL_MISSINGPATH 2
|
||||
#define LDAPTOOL_FILEURL_NONLOCAL 3
|
||||
#define LDAPTOOL_FILEURL_NOMEMORY 4
|
||||
596
mozilla/directory/c-sdk/ldap/clients/tools/ldapcmp.c
Normal file
596
mozilla/directory/c-sdk/ldap/clients/tools/ldapcmp.c
Normal file
@@ -0,0 +1,596 @@
|
||||
/* tool to compare the contents of two LDAP directory subtrees */
|
||||
|
||||
#include "ldaptool.h"
|
||||
|
||||
typedef struct attr {
|
||||
char *name;
|
||||
char **vals;
|
||||
struct attr *next;
|
||||
} ATTR; /* used for comparing two entries */
|
||||
|
||||
static void options_callback( int option, char *optarg );
|
||||
static int docompare( LDAP *ld1, LDAP *ld2, char *base );
|
||||
static int cmp2(LDAP *ld1, LDAP *ld2, LDAPMessage *e1, int findonly );
|
||||
static void notfound(char *base, int dbaseno);
|
||||
ATTR* get_attrs( LDAP *ld, LDAPMessage *e );
|
||||
char* cmp_attrs( ATTR *a1, ATTR *a2 );
|
||||
static void attr_free(ATTR *at);
|
||||
#if 0 /* these functions are not used */
|
||||
static void print_entry( LDAP *ld, LDAPMessage *entry, int attrsonly );
|
||||
static void print_dn( LDAP *ld, LDAPMessage *entry );
|
||||
static int write_ldif_value( char *type, char *value, unsigned long vallen );
|
||||
#endif /* 0 */
|
||||
|
||||
static void
|
||||
usage( void )
|
||||
{
|
||||
fprintf( stderr,
|
||||
"usage: %s -b basedn [options] [attributes...]\nwhere:\n",
|
||||
ldaptool_progname );
|
||||
fprintf( stderr, " basedn\tbase dn for search\n" );
|
||||
fprintf( stderr, "\t\t(if the environment variable LDAP_BASEDN is set,\n" );
|
||||
fprintf( stderr, "\t\tthen the -b flag is not required)\n" );
|
||||
fprintf( stderr, "options:\n" );
|
||||
ldaptool_common_usage( 1 );
|
||||
exit( LDAP_PARAM_ERROR );
|
||||
}
|
||||
|
||||
static char *base = NULL;
|
||||
static int allow_binary, vals2tmp, ldif, scope, deref;
|
||||
static int attrsonly, timelimit, sizelimit;
|
||||
#if 0 /* these statics are referenced only by unused functions */
|
||||
static char *sep = LDAPTOOL_DEFSEP;
|
||||
static char **sortattr = NULL;
|
||||
static int *skipsortattr = NULL;
|
||||
static int includeufn;
|
||||
#endif /* 0 */
|
||||
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
int rc, optind;
|
||||
LDAP *ld1, *ld2;
|
||||
|
||||
#ifdef HPUX11
|
||||
#ifndef __LP64__
|
||||
_main( argc, argv);
|
||||
#endif /* __LP64_ */
|
||||
#endif /* HPUX11 */
|
||||
|
||||
deref = allow_binary = vals2tmp = attrsonly = 0;
|
||||
ldif = 1;
|
||||
sizelimit = timelimit = 0;
|
||||
scope = LDAP_SCOPE_SUBTREE;
|
||||
|
||||
optind = ldaptool_process_args( argc, argv, "Bb:l:s:z:", 0,
|
||||
options_callback );
|
||||
|
||||
if ( base == NULL ) {
|
||||
if (( base = getenv( "LDAP_BASEDN" )) == NULL ) {
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
ld1 = ldaptool_ldap_init( 0 );
|
||||
|
||||
ldap_set_option( ld1, LDAP_OPT_DEREF, &deref );
|
||||
ldap_set_option( ld1, LDAP_OPT_TIMELIMIT, &timelimit );
|
||||
ldap_set_option( ld1, LDAP_OPT_SIZELIMIT, &sizelimit );
|
||||
|
||||
ldaptool_bind( ld1 );
|
||||
|
||||
ld2 = ldaptool_ldap_init( 1 );
|
||||
|
||||
ldap_set_option( ld2, LDAP_OPT_DEREF, &deref );
|
||||
ldap_set_option( ld2, LDAP_OPT_TIMELIMIT, &timelimit );
|
||||
ldap_set_option( ld2, LDAP_OPT_SIZELIMIT, &sizelimit );
|
||||
|
||||
ldaptool_bind( ld2 );
|
||||
if ( ldaptool_verbose ) {
|
||||
printf( "Connections to servers established. Beginning comparison.\n" );
|
||||
}
|
||||
|
||||
rc = docompare( ld1, ld2, base );
|
||||
|
||||
ldaptool_cleanup( ld1 );
|
||||
ldaptool_cleanup( ld2 );
|
||||
if ( ldaptool_verbose ) {
|
||||
if ( 0 == rc ) {
|
||||
printf( "compare completed: no differences found\n" );
|
||||
} else {
|
||||
printf( "compare completed: ****differences were found****\n" );
|
||||
}
|
||||
}
|
||||
return( rc );
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
options_callback( int option, char *optarg )
|
||||
{
|
||||
switch( option ) {
|
||||
case 'B': /* allow binary values to be printed, even if -o used */
|
||||
++allow_binary;
|
||||
break;
|
||||
case 's': /* search scope */
|
||||
if ( strncasecmp( optarg, "base", 4 ) == 0 ) {
|
||||
scope = LDAP_SCOPE_BASE;
|
||||
} else if ( strncasecmp( optarg, "one", 3 ) == 0 ) {
|
||||
scope = LDAP_SCOPE_ONELEVEL;
|
||||
} else if ( strncasecmp( optarg, "sub", 3 ) == 0 ) {
|
||||
scope = LDAP_SCOPE_SUBTREE;
|
||||
} else {
|
||||
fprintf( stderr, "scope should be base, one, or sub\n" );
|
||||
usage();
|
||||
}
|
||||
break;
|
||||
case 'b': /* searchbase */
|
||||
base = strdup( optarg );
|
||||
break;
|
||||
case 'l': /* time limit */
|
||||
timelimit = atoi( optarg );
|
||||
break;
|
||||
case 'z': /* size limit */
|
||||
sizelimit = atoi( optarg );
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns an LDAP error code.
|
||||
*/
|
||||
static int
|
||||
docompare( LDAP *ld1, LDAP *ld2, char *base )
|
||||
{
|
||||
int rc, msgid;
|
||||
LDAPMessage *res, *e;
|
||||
LDAPControl *ctrls[2], **serverctrls;
|
||||
|
||||
if ( ldaptool_verbose ) {
|
||||
printf( "Base: %s\n\n", base );
|
||||
}
|
||||
if ( ldaptool_not ) {
|
||||
return( LDAP_SUCCESS );
|
||||
}
|
||||
|
||||
if (( ctrls[0] = ldaptool_create_manage_dsait_control()) != NULL ) {
|
||||
ctrls[1] = NULL;
|
||||
serverctrls = ctrls;
|
||||
} else {
|
||||
serverctrls = NULL;
|
||||
}
|
||||
|
||||
if ( ldap_search_ext( ld1, base, LDAP_SCOPE_BASE, "objectClass=*", NULL,
|
||||
0, serverctrls, NULL, NULL, -1, &msgid ) != LDAP_SUCCESS ) {
|
||||
return( ldaptool_print_lderror( ld1, "ldap_search",
|
||||
LDAPTOOL_CHECK4SSL_IF_APPROP ));
|
||||
}
|
||||
/* XXXmcs: this code should be modified to display referrals and references */
|
||||
while ( (rc = ldap_result( ld1, LDAP_RES_ANY, 0, NULL, &res )) ==
|
||||
LDAP_RES_SEARCH_ENTRY ) {
|
||||
e = ldap_first_entry( ld1, res );
|
||||
rc = cmp2( ld1, ld2, e , 0);
|
||||
ldap_msgfree( res );
|
||||
}
|
||||
if ( rc == -1 ) {
|
||||
return( ldaptool_print_lderror( ld1, "ldap_result",
|
||||
LDAPTOOL_CHECK4SSL_IF_APPROP ));
|
||||
}
|
||||
if (( rc = ldap_result2error( ld1, res, 0 )) != LDAP_SUCCESS ) {
|
||||
ldaptool_print_lderror( ld1, "ldap_search",
|
||||
LDAPTOOL_CHECK4SSL_IF_APPROP );
|
||||
}
|
||||
ldap_msgfree( res );
|
||||
|
||||
if ( ldap_search_ext( ld2, base, LDAP_SCOPE_BASE, "objectClass=*", NULL,
|
||||
0, serverctrls, NULL, NULL, -1, &msgid ) == -1 ) {
|
||||
return( ldaptool_print_lderror( ld2, "ldap_search",
|
||||
LDAPTOOL_CHECK4SSL_IF_APPROP ));
|
||||
}
|
||||
/* XXXmcs: this code should be modified to display referrals and references */
|
||||
while ( (rc = ldap_result( ld2, LDAP_RES_ANY, 0, NULL, &res )) ==
|
||||
LDAP_RES_SEARCH_ENTRY ) {
|
||||
e = ldap_first_entry( ld2, res );
|
||||
rc = cmp2( ld2, ld1, e , 1);
|
||||
ldap_msgfree( res );
|
||||
}
|
||||
if ( rc == -1 ) {
|
||||
return( ldaptool_print_lderror( ld2, "ldap_result",
|
||||
LDAPTOOL_CHECK4SSL_IF_APPROP ));
|
||||
}
|
||||
if (( rc = ldap_result2error( ld1, res, 0 )) != LDAP_SUCCESS ) {
|
||||
ldaptool_print_lderror( ld1, "ldap_search",
|
||||
LDAPTOOL_CHECK4SSL_IF_APPROP );
|
||||
}
|
||||
ldap_msgfree( res );
|
||||
|
||||
return( rc );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns an LDAP error code.
|
||||
*/
|
||||
static int
|
||||
cmp2( LDAP *ld1, LDAP *ld2, LDAPMessage *e1, int findonly)
|
||||
{
|
||||
LDAPMessage *e2, *res;
|
||||
char *dn, *attrcmp;
|
||||
int found=0, rc, msgid;
|
||||
ATTR *a1, *a2;
|
||||
|
||||
dn = ldap_get_dn( ld1, e1 );
|
||||
|
||||
if ( ldaptool_verbose ) {
|
||||
if ( findonly ) {
|
||||
printf( "Checking that %s exists on both servers\n", dn );
|
||||
} else {
|
||||
printf("Comparing entry %s on both servers\n", dn );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ldap_search( ld2, dn, LDAP_SCOPE_BASE, "objectClass=*", NULL, 0 ) == -1 ) {
|
||||
return( ldaptool_print_lderror( ld2, "ldap_search",
|
||||
LDAPTOOL_CHECK4SSL_IF_APPROP ));
|
||||
}
|
||||
/* XXXmcs: this code should be modified to display referrals and references */
|
||||
while ( (rc = ldap_result( ld2, LDAP_RES_ANY, 0, NULL, &res )) ==
|
||||
LDAP_RES_SEARCH_ENTRY ) {
|
||||
e2 = ldap_first_entry( ld1, res );
|
||||
found = 1;
|
||||
if ( !findonly ) {
|
||||
a1 = get_attrs( ld1, e1 );
|
||||
a2 = get_attrs( ld2, e2 );
|
||||
attrcmp = cmp_attrs( a1, a2 );
|
||||
if ( strcmp( attrcmp, "") != 0 ) {
|
||||
printf("\n%s%s\n", dn, attrcmp);
|
||||
}
|
||||
}
|
||||
ldap_msgfree( res );
|
||||
}
|
||||
if ( !found ) {
|
||||
notfound( dn, findonly );
|
||||
}
|
||||
if ( rc == -1 ) {
|
||||
return( ldaptool_print_lderror( ld2, "ldap_result",
|
||||
LDAPTOOL_CHECK4SSL_IF_APPROP ));
|
||||
}
|
||||
ldap_msgfree( res );
|
||||
|
||||
if (( msgid = ldap_search( ld1, dn, LDAP_SCOPE_ONELEVEL, "objectClass=*" , NULL, 0 )) == -1 ) {
|
||||
return( ldaptool_print_lderror( ld1, "ldap_search",
|
||||
LDAPTOOL_CHECK4SSL_IF_APPROP ));
|
||||
}
|
||||
/* XXXmcs: this code should be modified to display referrals and references */
|
||||
while ( (rc = ldap_result( ld1, msgid, 0, NULL, &res )) ==
|
||||
LDAP_RES_SEARCH_ENTRY ) {
|
||||
e2 = ldap_first_entry( ld1, res );
|
||||
rc = cmp2( ld1, ld2, e2, findonly );
|
||||
ldap_msgfree( res );
|
||||
}
|
||||
if ( rc == -1 ) {
|
||||
return( ldaptool_print_lderror( ld1, "ldap_result",
|
||||
LDAPTOOL_CHECK4SSL_IF_APPROP ));
|
||||
}
|
||||
if (( rc = ldap_result2error( ld1, res, 0 )) != LDAP_SUCCESS ) {
|
||||
ldaptool_print_lderror( ld1, "ldap_search",
|
||||
LDAPTOOL_CHECK4SSL_IF_APPROP );
|
||||
}
|
||||
|
||||
ldap_msgfree( res );
|
||||
ldap_memfree( dn );
|
||||
return(rc);
|
||||
}
|
||||
|
||||
|
||||
ATTR*
|
||||
get_attrs( LDAP *ld, LDAPMessage *e )
|
||||
{
|
||||
char *a;
|
||||
ATTR *head, *tail, *tmp;
|
||||
BerElement *ber;
|
||||
|
||||
head=tail=tmp=NULL;
|
||||
for ( a = ldap_first_attribute( ld, e, &ber ); a != NULL;
|
||||
a = ldap_next_attribute( ld, e, ber ) ) {
|
||||
tmp = (ATTR*)malloc(sizeof(ATTR));
|
||||
if(head == NULL)
|
||||
head = tail = tmp;
|
||||
else {
|
||||
tail->next = tmp;
|
||||
tail = tmp;
|
||||
}
|
||||
tmp->name = a;
|
||||
tmp->vals = ldap_get_values( ld, e, a );
|
||||
tmp->next = NULL;
|
||||
}
|
||||
if ( ber != NULL ) {
|
||||
ber_free( ber, 0 );
|
||||
}
|
||||
/* used for debugging
|
||||
tmp=head;
|
||||
while(tmp!= NULL) {
|
||||
printf("\n%s :", tmp->name);
|
||||
for(i=0; tmp->vals[i] != NULL; i++)
|
||||
printf("\n\t%d %s", i, tmp->vals[i]);
|
||||
tmp = tmp->next;
|
||||
}
|
||||
*/
|
||||
return(head);
|
||||
}
|
||||
|
||||
|
||||
char*
|
||||
cmp_attrs( ATTR *a1, ATTR *a2 )
|
||||
{
|
||||
static char result[5000];
|
||||
char res[1000], partial[1000], *name = "";
|
||||
ATTR *head1, *head2, *tmp, *prev, *start;
|
||||
int i, j, found;
|
||||
|
||||
head1 = a1;
|
||||
head2 = a2;
|
||||
tmp = a2;
|
||||
prev = NULL;
|
||||
strcpy(result, "");
|
||||
while(head1 != NULL) {
|
||||
name = head1->name;
|
||||
if(head2 == NULL) {
|
||||
while(head1 != NULL) {
|
||||
sprintf(partial, "\ndifferent: %s(*)", head1->name);
|
||||
strcat(result, partial);
|
||||
for(i=0; head1->vals[i] != NULL; i++) {
|
||||
sprintf(partial,"\n\t1: %s", head1->vals[i]);
|
||||
strcat(result, partial);
|
||||
}
|
||||
tmp = head1;
|
||||
head1 = head1->next;
|
||||
attr_free(tmp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
name = head1->name;
|
||||
start = tmp;
|
||||
while(tmp != NULL) {
|
||||
if(!strcmp(name, tmp->name)) { /* attr found */
|
||||
strcpy(res, "");
|
||||
for(i=0; (head1->vals[i]) != NULL; i++) {
|
||||
found = 0;
|
||||
for(j=0; (tmp->vals[j]) != NULL; j++)
|
||||
if(!strcmp(head1->vals[i], tmp->vals[j])) {
|
||||
found = 1;
|
||||
tmp->vals[j][0] = 7;
|
||||
break;
|
||||
}
|
||||
if(!found) {
|
||||
sprintf(partial, "\n\t1: %s", head1->vals[i]);
|
||||
strcat(res, partial);
|
||||
}
|
||||
}
|
||||
for(j=0; tmp->vals[j] != NULL; j++)
|
||||
if(tmp->vals[j][0] != 7){
|
||||
sprintf(partial, "\n\t2: %s", tmp->vals[j]);
|
||||
strcat(res, partial);
|
||||
}
|
||||
|
||||
if(strcmp(res, "")) {
|
||||
sprintf(partial, "\ndifferent: %s%s", name, res);
|
||||
strcat(result, partial);
|
||||
}
|
||||
if(prev == NULL) { /* tmp = head2 */
|
||||
head2 = head2->next;
|
||||
attr_free(tmp);
|
||||
tmp = head2;
|
||||
}
|
||||
else {
|
||||
prev->next = tmp->next;
|
||||
attr_free(tmp);
|
||||
tmp = prev->next;
|
||||
if(tmp == NULL) {
|
||||
tmp = head2;
|
||||
prev = NULL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
else { /* attr not found */
|
||||
if(prev == NULL)
|
||||
prev = head2;
|
||||
else
|
||||
prev = tmp;
|
||||
tmp = tmp->next;
|
||||
if(tmp == NULL) { /* end of list */
|
||||
tmp = head2;
|
||||
prev = NULL;
|
||||
}
|
||||
if(tmp == start) { /* attr !exist in 2 */
|
||||
sprintf(partial, "\ndifferent: %s(*)", name);
|
||||
strcat(result, partial);
|
||||
for(i=0; head1->vals[i] != NULL; i++) {
|
||||
sprintf(partial, "\n\t1: %s", head1->vals[i]);
|
||||
strcat(result, partial);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
start = head1;
|
||||
head1 = head1->next;
|
||||
attr_free(start);
|
||||
}
|
||||
while(head2 != NULL) {
|
||||
sprintf(partial, "\ndifferent: %s(*)", head2->name);
|
||||
strcat(result, partial);
|
||||
for(i=0; head2->vals[i] != NULL; i++) {
|
||||
sprintf(partial, "\n\t2: %s", head2->vals[i]);
|
||||
strcat(result, partial);
|
||||
}
|
||||
tmp = head2;
|
||||
head2 = head2->next;
|
||||
attr_free(tmp);
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
attr_free(ATTR *at)
|
||||
{
|
||||
ldap_memfree(at->name);
|
||||
ldap_value_free(at->vals);
|
||||
free(at);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
notfound(char *base, int dbaseno)
|
||||
{
|
||||
printf("%donly: %s\n", dbaseno+1, base);
|
||||
}
|
||||
|
||||
|
||||
#if 0 /* these function is not used */
|
||||
/* used for debugging */
|
||||
static void
|
||||
print_dn( LDAP *ld, LDAPMessage *entry )
|
||||
{
|
||||
char *dn, *ufn;
|
||||
|
||||
dn = ldap_get_dn( ld, entry );
|
||||
if ( ldif ) {
|
||||
write_ldif_value( "dn", dn, strlen( dn ));
|
||||
} else {
|
||||
printf( "%s\n", dn );
|
||||
}
|
||||
if ( includeufn ) {
|
||||
ufn = ldap_dn2ufn( dn );
|
||||
if ( ldif ) {
|
||||
write_ldif_value( "ufn", ufn, strlen( ufn ));
|
||||
} else {
|
||||
printf( "%s\n", ufn );
|
||||
}
|
||||
free( ufn );
|
||||
}
|
||||
ldap_memfree( dn );
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
print_entry( ld, entry, attrsonly )
|
||||
LDAP *ld;
|
||||
LDAPMessage *entry;
|
||||
int attrsonly;
|
||||
{
|
||||
char *a, *dn, *ufn, tmpfname[ 256 ];
|
||||
int i, notascii;
|
||||
BerElement *ber;
|
||||
struct berval **bvals;
|
||||
FILE *tmpfp;
|
||||
#if defined( XP_WIN32 )
|
||||
char mode[20] = "w+b";
|
||||
#else
|
||||
char mode[20] = "w";
|
||||
#endif
|
||||
|
||||
dn = ldap_get_dn( ld, entry );
|
||||
if ( ldif ) {
|
||||
write_ldif_value( "dn", dn, strlen( dn ));
|
||||
} else {
|
||||
printf( "%s\n", dn );
|
||||
}
|
||||
if ( includeufn ) {
|
||||
ufn = ldap_dn2ufn( dn );
|
||||
if ( ldif ) {
|
||||
write_ldif_value( "ufn", ufn, strlen( ufn ));
|
||||
} else {
|
||||
printf( "%s\n", ufn );
|
||||
}
|
||||
free( ufn );
|
||||
}
|
||||
ldap_memfree( dn );
|
||||
|
||||
for ( a = ldap_first_attribute( ld, entry, &ber ); a != NULL;
|
||||
a = ldap_next_attribute( ld, entry, ber ) ) {
|
||||
if ( ldap_charray_inlist(sortattr, a) && /* in the list*/
|
||||
skipsortattr[ldap_charray_position(sortattr, a)] ) {/* and skip it*/
|
||||
continue; /* so skip it! */
|
||||
}
|
||||
if ( attrsonly ) {
|
||||
if ( ldif ) {
|
||||
write_ldif_value( a, "", 0 );
|
||||
} else {
|
||||
printf( "%s\n", a );
|
||||
}
|
||||
} else if (( bvals = ldap_get_values_len( ld, entry, a )) != NULL ) {
|
||||
for ( i = 0; bvals[i] != NULL; i++ ) {
|
||||
if ( vals2tmp ) {
|
||||
sprintf( tmpfname, "%s/ldapcmp-%s-XXXXXX",
|
||||
ldaptool_get_tmp_dir(), a );
|
||||
tmpfp = NULL;
|
||||
|
||||
if ( mktemp( tmpfname ) == NULL ) {
|
||||
perror( tmpfname );
|
||||
} else if (( tmpfp = fopen( tmpfname, mode)) == NULL ) {
|
||||
perror( tmpfname );
|
||||
} else if ( fwrite( bvals[ i ]->bv_val,
|
||||
bvals[ i ]->bv_len, 1, tmpfp ) == 0 ) {
|
||||
perror( tmpfname );
|
||||
} else if ( ldif ) {
|
||||
write_ldif_value( a, tmpfname, strlen( tmpfname ));
|
||||
} else {
|
||||
printf( "%s%s%s\n", a, sep, tmpfname );
|
||||
}
|
||||
|
||||
if ( tmpfp != NULL ) {
|
||||
fclose( tmpfp );
|
||||
}
|
||||
} else {
|
||||
notascii = 0;
|
||||
if ( !ldif && !allow_binary ) {
|
||||
unsigned long j;
|
||||
for ( j = 0; j < bvals[ i ]->bv_len; ++j ) {
|
||||
if ( !isascii( bvals[ i ]->bv_val[ j ] )) {
|
||||
notascii = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ldif ) {
|
||||
write_ldif_value( a, bvals[ i ]->bv_val,
|
||||
bvals[ i ]->bv_len );
|
||||
} else {
|
||||
printf( "%s%s%s\n", a, sep,
|
||||
notascii ? "NOT ASCII" : bvals[ i ]->bv_val );
|
||||
}
|
||||
}
|
||||
}
|
||||
ber_bvecfree( bvals );
|
||||
}
|
||||
}
|
||||
if ( ber != NULL ) {
|
||||
ber_free( ber, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
write_ldif_value( char *type, char *value, unsigned long vallen )
|
||||
{
|
||||
char *ldif;
|
||||
|
||||
if (( ldif = ldif_type_and_value( type, value, (int)vallen )) == NULL ) {
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
fputs( ldif, stdout );
|
||||
free( ldif );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* 0 */
|
||||
115
mozilla/directory/c-sdk/ldap/clients/tools/ldapdelete.c
Normal file
115
mozilla/directory/c-sdk/ldap/clients/tools/ldapdelete.c
Normal file
@@ -0,0 +1,115 @@
|
||||
/* ldapdelete.c - simple program to delete an entry using LDAP */
|
||||
|
||||
#include "ldaptool.h"
|
||||
|
||||
static int contoper;
|
||||
static LDAP *ld;
|
||||
|
||||
static int dodelete( LDAP *ld, char *dn, LDAPControl **serverctrls );
|
||||
static void options_callback( int option, char *optarg );
|
||||
|
||||
|
||||
static void
|
||||
usage( void )
|
||||
{
|
||||
fprintf( stderr, "usage: %s [options] [dn...]\n", ldaptool_progname );
|
||||
fprintf( stderr, "options:\n" );
|
||||
ldaptool_common_usage( 0 );
|
||||
fprintf( stderr, " -c\t\tcontinuous mode (do not stop on errors)\n" );
|
||||
fprintf( stderr, " -f file\tread DNs to delete from file\n" );
|
||||
exit( LDAP_PARAM_ERROR );
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
char buf[ 4096 ];
|
||||
int rc, deref, optind;
|
||||
LDAPControl *ldctrl;
|
||||
|
||||
|
||||
#ifdef HPUX11
|
||||
#ifndef __LP64__
|
||||
_main( argc, argv);
|
||||
#endif /* __LP64_ */
|
||||
#endif /* HPUX11 */
|
||||
|
||||
contoper = 0;
|
||||
|
||||
optind = ldaptool_process_args( argc, argv, "c", 0, options_callback );
|
||||
|
||||
if ( ldaptool_fp == NULL && optind >= argc ) {
|
||||
ldaptool_fp = stdin;
|
||||
}
|
||||
|
||||
ld = ldaptool_ldap_init( 0 );
|
||||
|
||||
deref = LDAP_DEREF_NEVER; /* prudent, but probably unnecessary */
|
||||
ldap_set_option( ld, LDAP_OPT_DEREF, &deref );
|
||||
|
||||
ldaptool_bind( ld );
|
||||
|
||||
if (( ldctrl = ldaptool_create_manage_dsait_control()) != NULL ) {
|
||||
ldaptool_add_control_to_array( ldctrl, ldaptool_request_ctrls);
|
||||
}
|
||||
|
||||
if ((ldctrl = ldaptool_create_proxyauth_control(ld)) !=NULL) {
|
||||
ldaptool_add_control_to_array( ldctrl, ldaptool_request_ctrls);
|
||||
}
|
||||
|
||||
if ( ldaptool_fp == NULL ) {
|
||||
for ( ; optind < argc; ++optind ) {
|
||||
char *conv;
|
||||
|
||||
conv = ldaptool_local2UTF8( argv[ optind ] );
|
||||
rc = dodelete( ld, conv, ldaptool_request_ctrls );
|
||||
if( conv != NULL )
|
||||
free( conv );
|
||||
}
|
||||
} else {
|
||||
rc = 0;
|
||||
while ((rc == 0 || contoper) &&
|
||||
fgets(buf, sizeof(buf), ldaptool_fp) != NULL) {
|
||||
buf[ strlen( buf ) - 1 ] = '\0'; /* remove trailing newline */
|
||||
if ( *buf != '\0' ) {
|
||||
rc = dodelete( ld, buf, ldaptool_request_ctrls );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ldaptool_reset_control_array( ldaptool_request_ctrls );
|
||||
ldaptool_cleanup( ld );
|
||||
return( rc );
|
||||
}
|
||||
|
||||
static void
|
||||
options_callback( int option, char *optarg )
|
||||
{
|
||||
switch( option ) {
|
||||
case 'c': /* continuous operation mode */
|
||||
++contoper;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
dodelete( LDAP *ld, char *dn, LDAPControl **serverctrls )
|
||||
{
|
||||
int rc;
|
||||
|
||||
if ( ldaptool_verbose ) {
|
||||
printf( "%sdeleting entry %s\n", ldaptool_not ? "!" : "", dn );
|
||||
}
|
||||
if ( ldaptool_not ) {
|
||||
rc = LDAP_SUCCESS;
|
||||
} else if (( rc = ldaptool_delete_ext_s( ld, dn, serverctrls, NULL,
|
||||
"ldap_delete" )) == LDAP_SUCCESS && ldaptool_verbose ) {
|
||||
printf( "entry removed\n" );
|
||||
}
|
||||
|
||||
return( rc );
|
||||
}
|
||||
1070
mozilla/directory/c-sdk/ldap/clients/tools/ldapmodify.c
Normal file
1070
mozilla/directory/c-sdk/ldap/clients/tools/ldapmodify.c
Normal file
File diff suppressed because it is too large
Load Diff
146
mozilla/directory/c-sdk/ldap/clients/tools/ldapmodrdn.c
Normal file
146
mozilla/directory/c-sdk/ldap/clients/tools/ldapmodrdn.c
Normal file
@@ -0,0 +1,146 @@
|
||||
/* ldapmodrdn.c - generic program to modify an entry's RDN using LDAP */
|
||||
|
||||
#include "ldaptool.h"
|
||||
|
||||
static int domodrdn( LDAP *ld, char *dn, char *rdn, int remove,
|
||||
LDAPControl **serverctrls);
|
||||
static void options_callback( int option, char *optarg );
|
||||
|
||||
static int contoper, remove_oldrdn;
|
||||
static LDAP *ld;
|
||||
|
||||
|
||||
static void
|
||||
usage( void )
|
||||
{
|
||||
fprintf( stderr, "usage: %s [options] [dn rdn]\n", ldaptool_progname );
|
||||
fprintf( stderr, "options:\n" );
|
||||
ldaptool_common_usage( 0 );
|
||||
fprintf( stderr, " -c\t\tcontinuous mode (do not stop on errors)\n" );
|
||||
fprintf( stderr, " -r\t\tremove old RDN\n" );
|
||||
fprintf( stderr, " -f file\tread changes from file\n" );
|
||||
exit( LDAP_PARAM_ERROR );
|
||||
}
|
||||
|
||||
|
||||
main( argc, argv )
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
char *entrydn, *rdn, buf[ 4096 ];
|
||||
int rc, havedn, deref, optind;
|
||||
LDAPControl *ctrls[2], **serverctrls;
|
||||
|
||||
contoper = remove_oldrdn = 0;
|
||||
|
||||
optind = ldaptool_process_args( argc, argv, "cr", 0, options_callback );
|
||||
|
||||
if ( ldaptool_fp == NULL ) {
|
||||
ldaptool_fp = stdin;
|
||||
}
|
||||
|
||||
havedn = 0;
|
||||
if (argc - optind == 2) {
|
||||
if (( rdn = strdup( argv[argc - 1] )) == NULL ) {
|
||||
perror( "strdup" );
|
||||
exit( LDAP_NO_MEMORY );
|
||||
}
|
||||
if (( entrydn = strdup( argv[argc - 2] )) == NULL ) {
|
||||
perror( "strdup" );
|
||||
exit( LDAP_NO_MEMORY );
|
||||
}
|
||||
++havedn;
|
||||
} else if ( argc - optind != 0 ) {
|
||||
fprintf( stderr, "%s: invalid number of arguments, only two allowed\n",
|
||||
ldaptool_progname );
|
||||
usage();
|
||||
}
|
||||
|
||||
ld = ldaptool_ldap_init( 0 );
|
||||
|
||||
if ( !ldaptool_not ) {
|
||||
deref = LDAP_DEREF_NEVER; /* this seems prudent */
|
||||
ldap_set_option( ld, LDAP_OPT_DEREF, &deref );
|
||||
}
|
||||
|
||||
ldaptool_bind( ld );
|
||||
|
||||
if (( ctrls[0] = ldaptool_create_manage_dsait_control()) != NULL ) {
|
||||
ctrls[1] = NULL;
|
||||
serverctrls = ctrls;
|
||||
} else {
|
||||
serverctrls = NULL;
|
||||
}
|
||||
|
||||
rc = 0;
|
||||
if (havedn) {
|
||||
rc = domodrdn(ld, entrydn, rdn, remove_oldrdn, serverctrls);
|
||||
} else while ((rc == 0 || contoper) &&
|
||||
fgets(buf, sizeof(buf), ldaptool_fp) != NULL) {
|
||||
if ( *buf != '\0' && *buf != '\n' ) { /* skip blank lines */
|
||||
buf[ strlen( buf ) - 1 ] = '\0'; /* remove nl */
|
||||
|
||||
if ( havedn ) { /* have DN, get RDN */
|
||||
if (( rdn = strdup( buf )) == NULL ) {
|
||||
perror( "strdup" );
|
||||
exit( LDAP_NO_MEMORY );
|
||||
}
|
||||
rc = domodrdn(ld, entrydn, rdn, remove_oldrdn, serverctrls);
|
||||
havedn = 0;
|
||||
} else if ( !havedn ) { /* don't have DN yet */
|
||||
if (( entrydn = strdup( buf )) == NULL ) {
|
||||
perror( "strdup" );
|
||||
exit( LDAP_NO_MEMORY );
|
||||
}
|
||||
++havedn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ldaptool_cleanup( ld );
|
||||
exit( rc );
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
options_callback( int option, char *optarg )
|
||||
{
|
||||
switch( option ) {
|
||||
case 'c': /* continuous operation mode */
|
||||
++contoper;
|
||||
break;
|
||||
case 'r': /* remove old RDN */
|
||||
++remove_oldrdn;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
domodrdn( LDAP *ld, char *dn, char *rdn, int remove_oldrdn,
|
||||
LDAPControl **serverctrls )
|
||||
{
|
||||
int i;
|
||||
|
||||
if ( ldaptool_verbose ) {
|
||||
printf( "modrdn %s:\n\t%s\n", dn, rdn );
|
||||
if (remove_oldrdn)
|
||||
printf("removing old RDN\n");
|
||||
else
|
||||
printf("keeping old RDN\n");
|
||||
}
|
||||
|
||||
if ( !ldaptool_not ) {
|
||||
if (( i = ldaptool_rename_s( ld, dn, rdn, NULL, remove_oldrdn,
|
||||
serverctrls, NULL, "ldap_rename" )) == LDAP_SUCCESS
|
||||
&& ldaptool_verbose ) {
|
||||
printf( "modrdn complete\n" );
|
||||
}
|
||||
} else {
|
||||
i = LDAP_SUCCESS;
|
||||
}
|
||||
|
||||
return( i );
|
||||
}
|
||||
935
mozilla/directory/c-sdk/ldap/clients/tools/ldapsearch.c
Normal file
935
mozilla/directory/c-sdk/ldap/clients/tools/ldapsearch.c
Normal file
@@ -0,0 +1,935 @@
|
||||
/* ldapsearch.c - generic program to search LDAP */
|
||||
|
||||
#include "ldaptool.h"
|
||||
#include "fileurl.h"
|
||||
|
||||
#define VLV_PARAM_SEP ':'
|
||||
|
||||
static void usage( void );
|
||||
static int dosearch( LDAP *ld, char *base, int scope, char **attrs,
|
||||
int attrsonly, char *filtpatt, char *value);
|
||||
static int write_ldif_value( char *type, char *value, unsigned long vallen,
|
||||
unsigned long ldifoptions );
|
||||
static void print_entry( LDAP *ld, LDAPMessage *entry, int attrsonly );
|
||||
static void options_callback( int option, char *optarg );
|
||||
static void parse_and_display_reference( LDAP *ld, LDAPMessage *ref );
|
||||
static char *sortresult2string(unsigned long result);
|
||||
static char *msgtype2str( int msgtype );
|
||||
|
||||
|
||||
static void
|
||||
usage( void )
|
||||
{
|
||||
fprintf( stderr, "usage: %s -b basedn [options] filter [attributes...]\n", ldaptool_progname );
|
||||
fprintf( stderr, " %s -b basedn [options] -f file [attributes...]\nwhere:\n", ldaptool_progname );
|
||||
fprintf( stderr, " basedn\tbase dn for search\n" );
|
||||
fprintf( stderr, "\t\t(if the environment variable LDAP_BASEDN is set,\n" );
|
||||
fprintf( stderr, "\t\tthen the -b flag is not required)\n" );
|
||||
fprintf( stderr, " filter\tRFC-2254 compliant LDAP search filter\n" );
|
||||
fprintf( stderr, " file\tfile containing a sequence of LDAP search filters to use\n" );
|
||||
fprintf( stderr, " attributes\twhitespace-separated list of attributes to retrieve\n" );
|
||||
fprintf( stderr, "\t\t(if no attribute list is given, all are retrieved)\n" );
|
||||
fprintf( stderr, "options:\n" );
|
||||
ldaptool_common_usage( 0 );
|
||||
#if defined( XP_WIN32 )
|
||||
fprintf( stderr, " -t\t\twrite values to files in temp directory.\n" );
|
||||
#else
|
||||
fprintf( stderr, " -t\t\twrite values to files in /tmp\n" );
|
||||
#endif
|
||||
fprintf( stderr, " -U\t\tproduce file URLs in conjunction with -t\n" );
|
||||
fprintf( stderr, " -e\t\tminimize base-64 encoding of values\n" );
|
||||
fprintf( stderr, " -u\t\tinclude User Friendly entry names in the output\n" );
|
||||
fprintf( stderr, " -o\t\tprint entries using old format (default is LDIF)\n" );
|
||||
fprintf( stderr, " -T\t\tdon't fold (wrap) long lines (default is to fold)\n" );
|
||||
fprintf( stderr, " -1\t\tomit leading \"version: %d\" line in LDIF output\n", LDIF_VERSION_ONE );
|
||||
fprintf( stderr, " -A\t\tretrieve attribute names only (no values)\n" );
|
||||
fprintf( stderr, " -B\t\tprint non-ASCII values when old format (-o) is used\n" );
|
||||
fprintf( stderr, " -x\t\tperforming sorting on server\n" );
|
||||
fprintf( stderr, " -F sep\tprint `sep' instead of `=' between attribute names and values\n" );
|
||||
fprintf( stderr, " -S attr\tsort the results by attribute `attr'\n" );
|
||||
fprintf( stderr, " -s scope\tone of base, one, or sub (search scope)\n" );
|
||||
fprintf( stderr, " -a deref\tone of never, always, search, or find (alias dereferencing)\n" );
|
||||
fprintf( stderr, " -l time lim\ttime limit (in seconds) for search\n" );
|
||||
fprintf( stderr, " -z size lim\tsize limit (in entries) for search\n" );
|
||||
fprintf( stderr, " -G before:after:index:count | before:after:value where 'before' and\n");
|
||||
fprintf( stderr, "\t\t'after' are the number of entries surrounding 'index.'\n");
|
||||
fprintf( stderr, "\t\t'count' is the content count, 'value' is the search value.\n");
|
||||
|
||||
exit( LDAP_PARAM_ERROR );
|
||||
}
|
||||
|
||||
static char *base = NULL;
|
||||
static char *sep = LDAPTOOL_DEFSEP;
|
||||
static char **sortattr = NULL;
|
||||
static char *vlv_value = NULL;
|
||||
static int sortsize = 0;
|
||||
static int *skipsortattr = NULL;
|
||||
static int includeufn, allow_binary, vals2tmp, ldif, scope, deref;
|
||||
static int attrsonly, timelimit, sizelimit, server_sort, fold;
|
||||
static int minimize_base64, produce_file_urls;
|
||||
static int use_vlv = 0, vlv_before, vlv_after, vlv_index, vlv_count;
|
||||
static int write_ldif_version = 1;
|
||||
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
char *filtpattern, **attrs, line[ BUFSIZ ];
|
||||
int rc, optind, i, first;
|
||||
LDAP *ld;
|
||||
|
||||
deref = allow_binary = vals2tmp = attrsonly = 0;
|
||||
minimize_base64 = produce_file_urls = 0;
|
||||
ldif = 1;
|
||||
fold = 1;
|
||||
sizelimit = timelimit = 0;
|
||||
scope = LDAP_SCOPE_SUBTREE;
|
||||
server_sort = 0;
|
||||
|
||||
|
||||
#ifdef HPUX11
|
||||
#ifndef __LP64__
|
||||
_main( argc, argv);
|
||||
#endif /* __LP64_ */
|
||||
#endif /* HPUX11 */
|
||||
|
||||
|
||||
optind = ldaptool_process_args( argc, argv, "ABLTU1eotuxa:b:F:G:l:S:s:z:",
|
||||
0, options_callback );
|
||||
|
||||
if ( base == NULL ) {
|
||||
if (( base = getenv( "LDAP_BASEDN" )) == NULL ) {
|
||||
usage();
|
||||
}
|
||||
}
|
||||
if ( sortattr ) {
|
||||
for ( sortsize = 0; sortattr[sortsize] != NULL; sortsize++ ) {
|
||||
; /* NULL */
|
||||
}
|
||||
sortsize++; /* add in the final NULL field */
|
||||
skipsortattr = (int *) malloc( sortsize * sizeof(int *) );
|
||||
if ( skipsortattr == NULL ) {
|
||||
fprintf( stderr, "Out of memory\n" );
|
||||
exit( LDAP_NO_MEMORY );
|
||||
}
|
||||
memset( (char *) skipsortattr, 0, sortsize * sizeof(int *) );
|
||||
} else if ( server_sort ) {
|
||||
server_sort = 0; /* ignore this option if no sortattrs were given */
|
||||
}
|
||||
|
||||
if ( argc - optind < 1 ) {
|
||||
if ( ldaptool_fp == NULL ) {
|
||||
usage();
|
||||
}
|
||||
attrs = NULL;
|
||||
filtpattern = "%s";
|
||||
} else { /* there are additional args (filter + attrs) */
|
||||
if ( ldaptool_fp == NULL || strstr( argv[ optind ], "%s" ) != NULL ) {
|
||||
filtpattern = ldaptool_local2UTF8( argv[ optind ] );
|
||||
++optind;
|
||||
} else {
|
||||
filtpattern = "%s";
|
||||
}
|
||||
|
||||
if ( argv[ optind ] == NULL ) {
|
||||
attrs = NULL;
|
||||
} else if ( sortattr == NULL || *sortattr == '\0' || server_sort) {
|
||||
attrs = &argv[ optind ];
|
||||
} else {
|
||||
attrs = ldap_charray_dup( &argv[ optind ] );
|
||||
if ( attrs == NULL ) {
|
||||
fprintf( stderr, "Out of memory\n" );
|
||||
exit( LDAP_NO_MEMORY );
|
||||
}
|
||||
for ( i = 0; i < (sortsize - 1); i++ ) {
|
||||
if ( !ldap_charray_inlist( attrs, sortattr[i] ) ) {
|
||||
if ( ldap_charray_add( &attrs, sortattr[i] ) != 0 ) {
|
||||
fprintf( stderr, "Out of memory\n" );
|
||||
exit( LDAP_NO_MEMORY );
|
||||
}
|
||||
/*
|
||||
* attribute in the search list only for the purpose of
|
||||
* sorting
|
||||
*/
|
||||
skipsortattr[i] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ld = ldaptool_ldap_init( 0 );
|
||||
|
||||
if ( !ldaptool_not ) {
|
||||
ldap_set_option( ld, LDAP_OPT_DEREF, &deref );
|
||||
ldap_set_option( ld, LDAP_OPT_TIMELIMIT, &timelimit );
|
||||
ldap_set_option( ld, LDAP_OPT_SIZELIMIT, &sizelimit );
|
||||
}
|
||||
|
||||
ldaptool_bind( ld );
|
||||
|
||||
if ( ldaptool_verbose ) {
|
||||
printf( "filter pattern: %s\nreturning: ", filtpattern );
|
||||
if ( attrs == NULL ) {
|
||||
printf( "ALL" );
|
||||
} else {
|
||||
for ( i = 0; attrs[ i ] != NULL; ++i ) {
|
||||
printf( "%s ", attrs[ i ] );
|
||||
}
|
||||
}
|
||||
putchar( '\n' );
|
||||
}
|
||||
|
||||
if ( ldaptool_fp == NULL ) {
|
||||
char *conv;
|
||||
|
||||
conv = ldaptool_local2UTF8( base );
|
||||
rc = dosearch( ld, conv, scope, attrs, attrsonly, filtpattern, "" );
|
||||
if( conv != NULL )
|
||||
free( conv );
|
||||
} else {
|
||||
rc = LDAP_SUCCESS;
|
||||
first = 1;
|
||||
while ( rc == LDAP_SUCCESS &&
|
||||
fgets( line, sizeof( line ), ldaptool_fp ) != NULL ) {
|
||||
line[ strlen( line ) - 1 ] = '\0';
|
||||
if ( !first ) {
|
||||
putchar( '\n' );
|
||||
} else {
|
||||
first = 0;
|
||||
}
|
||||
rc = dosearch( ld, base, scope, attrs, attrsonly, filtpattern,
|
||||
line );
|
||||
}
|
||||
}
|
||||
|
||||
ldaptool_cleanup( ld );
|
||||
return( rc );
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
options_callback( int option, char *optarg )
|
||||
{
|
||||
char *s;
|
||||
|
||||
switch( option ) {
|
||||
case 'u': /* include UFN */
|
||||
++includeufn;
|
||||
break;
|
||||
case 't': /* write attribute values to /tmp files */
|
||||
++vals2tmp;
|
||||
break;
|
||||
case 'U': /* produce file URLs in conjunction with -t */
|
||||
++produce_file_urls;
|
||||
break;
|
||||
case 'e': /* minimize base-64 encoding of values */
|
||||
++minimize_base64;
|
||||
break;
|
||||
case 'A': /* retrieve attribute names only -- no values */
|
||||
++attrsonly;
|
||||
break;
|
||||
case 'L': /* print entries in LDIF format -- now the default */
|
||||
break;
|
||||
case 'o': /* print entries using old ldapsearch format */
|
||||
ldif = 0;
|
||||
break;
|
||||
case 'B': /* allow binary values to be printed, even if -o used */
|
||||
++allow_binary;
|
||||
break;
|
||||
case '1': /* omit leading "version: #" line from LDIF output */
|
||||
write_ldif_version = 0;
|
||||
break;
|
||||
case 's': /* search scope */
|
||||
if ( strncasecmp( optarg, "base", 4 ) == 0 ) {
|
||||
scope = LDAP_SCOPE_BASE;
|
||||
} else if ( strncasecmp( optarg, "one", 3 ) == 0 ) {
|
||||
scope = LDAP_SCOPE_ONELEVEL;
|
||||
} else if ( strncasecmp( optarg, "sub", 3 ) == 0 ) {
|
||||
scope = LDAP_SCOPE_SUBTREE;
|
||||
} else {
|
||||
fprintf( stderr, "scope should be base, one, or sub\n" );
|
||||
usage();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'a': /* set alias deref option */
|
||||
if ( strncasecmp( optarg, "never", 5 ) == 0 ) {
|
||||
deref = LDAP_DEREF_NEVER;
|
||||
} else if ( strncasecmp( optarg, "search", 5 ) == 0 ) {
|
||||
deref = LDAP_DEREF_SEARCHING;
|
||||
} else if ( strncasecmp( optarg, "find", 4 ) == 0 ) {
|
||||
deref = LDAP_DEREF_FINDING;
|
||||
} else if ( strncasecmp( optarg, "always", 6 ) == 0 ) {
|
||||
deref = LDAP_DEREF_ALWAYS;
|
||||
} else {
|
||||
fprintf( stderr, "alias deref should be never, search, find, or always\n" );
|
||||
usage();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'F': /* field separator */
|
||||
sep = strdup( optarg );
|
||||
break;
|
||||
case 'b': /* searchbase */
|
||||
base = strdup( optarg );
|
||||
break;
|
||||
case 'l': /* time limit */
|
||||
timelimit = atoi( optarg );
|
||||
break;
|
||||
case 'x': /* server sorting requested */
|
||||
server_sort = 1;
|
||||
break;
|
||||
case 'z': /* size limit */
|
||||
sizelimit = atoi( optarg );
|
||||
break;
|
||||
case 'S': /* sort attribute */
|
||||
ldap_charray_add( &sortattr, strdup( optarg ) );
|
||||
break;
|
||||
case 'T': /* don't fold lines */
|
||||
fold = 0;
|
||||
break;
|
||||
case 'G': /* do the virtual list setup */
|
||||
use_vlv++;
|
||||
s = strchr(optarg, VLV_PARAM_SEP );
|
||||
|
||||
if (s != NULL)
|
||||
{
|
||||
vlv_before = atoi(optarg);
|
||||
s++;
|
||||
vlv_after = atoi( s );
|
||||
s = strchr(s, VLV_PARAM_SEP );
|
||||
if (s != NULL)
|
||||
{
|
||||
s++;
|
||||
/* below is a small set of logic to implement the following cases
|
||||
* -G23:23:wilber
|
||||
* -G23:23:"wilber:wright"
|
||||
* -G23:23:'wilber'
|
||||
* -G23:23:wilber wright
|
||||
* all of the above are before, after, value - NOTE: a colon not in a quoted
|
||||
* string will break the parser!!!!
|
||||
* -G23:23:45:600
|
||||
* above is index, count encoding
|
||||
*/
|
||||
|
||||
if (*s == '\'' || *s == '"')
|
||||
{
|
||||
vlv_value = strdup( s );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strchr( s, VLV_PARAM_SEP ))
|
||||
{
|
||||
/* we have an index + count option */
|
||||
vlv_index = atoi( s );
|
||||
vlv_count = atoi( strchr( s, VLV_PARAM_SEP) + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* we don't have a quote surrounding the assertion value
|
||||
* do we need to???
|
||||
*/
|
||||
vlv_value = strdup( s );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( stderr,"Illegal 'after' paramater for virtual list\n" );
|
||||
exit( LDAP_PARAM_ERROR );
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( stderr,"Illegal 'before' paramater for virtual list\n" );
|
||||
exit( LDAP_PARAM_ERROR );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
dosearch( ld, base, scope, attrs, attrsonly, filtpatt, value )
|
||||
LDAP *ld;
|
||||
char *base;
|
||||
int scope;
|
||||
char **attrs;
|
||||
int attrsonly;
|
||||
char *filtpatt;
|
||||
char *value;
|
||||
{
|
||||
char **refs = NULL, filter[ BUFSIZ ];
|
||||
int rc, first, matches;
|
||||
LDAPMessage *res, *e;
|
||||
LDAPControl *ldctrl;
|
||||
LDAPControl **ctrl_response_array = NULL;
|
||||
LDAPVirtualList vlv_data;
|
||||
int msgid = 0;
|
||||
|
||||
#ifdef HAVE_SNPRINTF
|
||||
if ( snprintf( filter, sizeof(filter), filtpatt, value ) < 0 ) {
|
||||
perror( "snprintf filter (filter and/or pattern too long?)" );
|
||||
exit( LDAP_PARAM_ERROR );
|
||||
}
|
||||
#else
|
||||
sprintf( filter, filtpatt, value );
|
||||
#endif
|
||||
|
||||
if ( *filter == '\0' ) { /* treat empty filter is a shortcut for oc=* */
|
||||
strcpy( filter, "(objectclass=*)" );
|
||||
}
|
||||
|
||||
if ( ldaptool_verbose ) {
|
||||
printf( "filter is: (%s)\n", filter );
|
||||
}
|
||||
|
||||
if ( ldaptool_not ) {
|
||||
return( LDAP_SUCCESS );
|
||||
}
|
||||
|
||||
if (( ldctrl = ldaptool_create_manage_dsait_control()) != NULL ) {
|
||||
ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls);
|
||||
}
|
||||
|
||||
if ((ldctrl = ldaptool_create_proxyauth_control(ld)) !=NULL) {
|
||||
ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls);
|
||||
}
|
||||
|
||||
|
||||
if (server_sort) {
|
||||
/* First make a sort key list from the attribute list we have */
|
||||
LDAPsortkey **keylist = NULL;
|
||||
int i = 0;
|
||||
char *sortattrs = NULL;
|
||||
char *s = NULL;
|
||||
int string_length = 0;
|
||||
|
||||
/* Count the sort strings */
|
||||
for (i = 0; i < sortsize - 1 ; i++) {
|
||||
string_length += strlen(sortattr[i]) + 1;
|
||||
}
|
||||
|
||||
sortattrs = (char *) malloc(string_length + 1);
|
||||
if (NULL == sortattrs) {
|
||||
fprintf( stderr, "Out of memory\n" );
|
||||
exit( LDAP_NO_MEMORY );
|
||||
}
|
||||
|
||||
s = sortattrs;
|
||||
for (i = 0; i < sortsize - 1 ; i++) {
|
||||
memcpy(s, sortattr[i], strlen(sortattr[i]));
|
||||
s += strlen(sortattr[i]);
|
||||
*s++ = ' ';
|
||||
}
|
||||
|
||||
sortattrs[string_length] = '\0';
|
||||
|
||||
ldap_create_sort_keylist(&keylist,sortattrs);
|
||||
free(sortattrs);
|
||||
sortattrs = NULL;
|
||||
|
||||
/* Then make a control for the sort attributes we have */
|
||||
rc = ldap_create_sort_control(ld,keylist,0,&ldctrl);
|
||||
ldap_free_sort_keylist(keylist);
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
return( ldaptool_print_lderror( ld, "ldap_create_sort_control",
|
||||
LDAPTOOL_CHECK4SSL_IF_APPROP ));
|
||||
}
|
||||
|
||||
ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls);
|
||||
|
||||
}
|
||||
/* remember server side sorting must be available for vlv!!!! */
|
||||
|
||||
if (use_vlv)
|
||||
{
|
||||
vlv_data.ldvlist_before_count = vlv_before;
|
||||
vlv_data.ldvlist_after_count = vlv_after;
|
||||
if ( ldaptool_verbose ) {
|
||||
printf( "vlv data %lu, %lu, ",
|
||||
vlv_data.ldvlist_before_count,
|
||||
vlv_data.ldvlist_after_count
|
||||
);
|
||||
}
|
||||
if (vlv_value)
|
||||
{
|
||||
vlv_data.ldvlist_attrvalue = vlv_value;
|
||||
vlv_data.ldvlist_size = 0;
|
||||
vlv_data.ldvlist_index = 0;
|
||||
if ( ldaptool_verbose ) {
|
||||
printf( "%s, 0, 0\n", vlv_data.ldvlist_attrvalue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vlv_data.ldvlist_attrvalue = NULL;
|
||||
vlv_data.ldvlist_size = vlv_count;
|
||||
vlv_data.ldvlist_index = vlv_index;
|
||||
if ( ldaptool_verbose ) {
|
||||
printf( "(null), %lu, %lu\n", vlv_data.ldvlist_size, vlv_data.ldvlist_index );
|
||||
}
|
||||
}
|
||||
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
return( ldaptool_print_lderror( ld, "ldap_create_sort_control",
|
||||
LDAPTOOL_CHECK4SSL_IF_APPROP ));
|
||||
}
|
||||
if (LDAP_SUCCESS != (rc = ldap_create_virtuallist_control(ld,
|
||||
&vlv_data, &ldctrl)))
|
||||
{
|
||||
return( ldaptool_print_lderror( ld,
|
||||
"ldap_create_virtuallist_control",
|
||||
LDAPTOOL_CHECK4SSL_IF_APPROP ));
|
||||
}
|
||||
|
||||
ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls);
|
||||
|
||||
}
|
||||
|
||||
if ( ldap_search_ext( ld, base, scope, filter, attrs, attrsonly,
|
||||
ldaptool_request_ctrls, NULL, NULL, -1, &msgid )
|
||||
!= LDAP_SUCCESS ) {
|
||||
return( ldaptool_print_lderror( ld, "ldap_search",
|
||||
LDAPTOOL_CHECK4SSL_IF_APPROP ));
|
||||
}
|
||||
|
||||
ldaptool_reset_control_array( ldaptool_request_ctrls );
|
||||
|
||||
matches = 0;
|
||||
first = 1;
|
||||
if ( sortattr && !server_sort ) {
|
||||
rc = ldap_result( ld, LDAP_RES_ANY, 1, NULL, &res );
|
||||
} else {
|
||||
while ( (rc = ldap_result( ld, LDAP_RES_ANY, 0, NULL, &res )) !=
|
||||
LDAP_RES_SEARCH_RESULT && rc != -1 ) {
|
||||
if ( rc != LDAP_RES_SEARCH_ENTRY ) {
|
||||
if ( rc == LDAP_RES_SEARCH_REFERENCE ) {
|
||||
parse_and_display_reference( ld, res );
|
||||
} else if ( rc == LDAP_RES_EXTENDED
|
||||
&& ldap_msgid( res ) == LDAP_RES_UNSOLICITED ) {
|
||||
ldaptool_print_extended_response( ld, res,
|
||||
"Unsolicited response" );
|
||||
} else {
|
||||
fprintf( stderr, "%s: ignoring LDAP response message"
|
||||
" type 0x%x (%s)\n",
|
||||
ldaptool_progname, rc, msgtype2str( rc ));
|
||||
}
|
||||
ldap_msgfree( res );
|
||||
continue;
|
||||
}
|
||||
matches++;
|
||||
e = ldap_first_entry( ld, res );
|
||||
if ( !first ) {
|
||||
putchar( '\n' );
|
||||
} else {
|
||||
first = 0;
|
||||
}
|
||||
print_entry( ld, e, attrsonly );
|
||||
ldap_msgfree( res );
|
||||
}
|
||||
}
|
||||
if ( rc == -1 ) {
|
||||
return( ldaptool_print_lderror( ld, "ldap_result",
|
||||
LDAPTOOL_CHECK4SSL_IF_APPROP ));
|
||||
}
|
||||
|
||||
if ( ldap_parse_result( ld, res, &rc, NULL, NULL, &refs,
|
||||
&ctrl_response_array, 0 ) != LDAP_SUCCESS ) {
|
||||
ldaptool_print_lderror( ld, "ldap_parse_result",
|
||||
LDAPTOOL_CHECK4SSL_IF_APPROP );
|
||||
} else if ( rc != LDAP_SUCCESS ) {
|
||||
ldaptool_print_lderror( ld, "ldap_search",
|
||||
LDAPTOOL_CHECK4SSL_IF_APPROP );
|
||||
}
|
||||
/* Parse the returned sort control */
|
||||
if (server_sort) {
|
||||
unsigned long result = 0;
|
||||
char *attribute;
|
||||
|
||||
if ( LDAP_SUCCESS != ldap_parse_sort_control(ld,ctrl_response_array,&result,&attribute) ) {
|
||||
ldaptool_print_lderror(ld, "ldap_parse_sort_control",
|
||||
LDAPTOOL_CHECK4SSL_IF_APPROP );
|
||||
ldap_controls_free(ctrl_response_array);
|
||||
ldap_msgfree(res);
|
||||
return ( ldap_get_lderrno( ld, NULL, NULL ) );
|
||||
}
|
||||
|
||||
if (0 == result) {
|
||||
if ( ldaptool_verbose ) {
|
||||
printf( "Server indicated results sorted OK\n");
|
||||
}
|
||||
} else {
|
||||
if (NULL != attribute) {
|
||||
printf("Server reported sorting error %ld: %s, attribute in error\"%s\"\n",result,sortresult2string(result),attribute);
|
||||
} else {
|
||||
printf("Server reported sorting error %ld: %s\n",result,sortresult2string(result));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (use_vlv)
|
||||
{
|
||||
unsigned long vpos, vcount;
|
||||
int vresult;
|
||||
if ( LDAP_SUCCESS != ldap_parse_virtuallist_control(ld,ctrl_response_array,&vpos, &vcount,&vresult) ) {
|
||||
ldaptool_print_lderror( ld, "ldap_parse_virtuallist_control",
|
||||
LDAPTOOL_CHECK4SSL_IF_APPROP );
|
||||
ldap_controls_free(ctrl_response_array);
|
||||
ldap_msgfree(res);
|
||||
return ( ldap_get_lderrno( ld, NULL, NULL ) );
|
||||
}
|
||||
|
||||
if (0 == vresult) {
|
||||
if ( ldaptool_verbose ) {
|
||||
printf( "Server indicated virtual list positioning OK\n");
|
||||
}
|
||||
printf("index %lu content count %lu\n", vpos, vcount);
|
||||
|
||||
} else {
|
||||
printf("Server reported sorting error %d: %s\n",vresult,sortresult2string(vresult));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ldap_controls_free(ctrl_response_array);
|
||||
|
||||
if ( sortattr != NULL && !server_sort) {
|
||||
|
||||
(void) ldap_multisort_entries( ld, &res,
|
||||
( *sortattr == NULL ) ? NULL : sortattr,
|
||||
(LDAP_CMP_CALLBACK *)strcasecmp );
|
||||
matches = 0;
|
||||
first = 1;
|
||||
for ( e = ldap_first_entry( ld, res ); e != NULLMSG;
|
||||
e = ldap_next_entry( ld, e ) ) {
|
||||
matches++;
|
||||
if ( !first ) {
|
||||
putchar( '\n' );
|
||||
} else {
|
||||
first = 0;
|
||||
}
|
||||
print_entry( ld, e, attrsonly );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ldaptool_verbose ) {
|
||||
printf( "%d matches\n", matches );
|
||||
}
|
||||
|
||||
if ( refs != NULL ) {
|
||||
ldaptool_print_referrals( refs );
|
||||
ldap_value_free( refs );
|
||||
}
|
||||
|
||||
ldap_msgfree( res );
|
||||
return( rc );
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
print_entry( ld, entry, attrsonly )
|
||||
LDAP *ld;
|
||||
LDAPMessage *entry;
|
||||
int attrsonly;
|
||||
{
|
||||
char *a, *dn, *ufn, tmpfname[ BUFSIZ ];
|
||||
int i, notascii;
|
||||
BerElement *ber;
|
||||
struct berval **bvals;
|
||||
FILE *tmpfp;
|
||||
#if defined( XP_WIN32 )
|
||||
char mode[20] = "w+b";
|
||||
#else
|
||||
char mode[20] = "w";
|
||||
#endif
|
||||
|
||||
dn = ldap_get_dn( ld, entry );
|
||||
if ( ldif ) {
|
||||
write_ldif_value( "dn", dn, strlen( dn ), 0 );
|
||||
} else {
|
||||
printf( "%s\n", dn );
|
||||
}
|
||||
if ( includeufn ) {
|
||||
ufn = ldap_dn2ufn( dn );
|
||||
if ( ldif ) {
|
||||
write_ldif_value( "ufn", ufn, strlen( ufn ), 0 );
|
||||
} else {
|
||||
printf( "%s\n", ufn );
|
||||
}
|
||||
free( ufn );
|
||||
}
|
||||
ldap_memfree( dn );
|
||||
|
||||
for ( a = ldap_first_attribute( ld, entry, &ber ); a != NULL;
|
||||
a = ldap_next_attribute( ld, entry, ber ) ) {
|
||||
if ( ldap_charray_inlist(sortattr, a) && /* in the list*/
|
||||
skipsortattr[ldap_charray_position(sortattr, a)] ) {/* and skip it*/
|
||||
continue; /* so skip it! */
|
||||
}
|
||||
if ( attrsonly ) {
|
||||
if ( ldif ) {
|
||||
write_ldif_value( a, "", 0, 0 );
|
||||
} else {
|
||||
printf( "%s\n", a );
|
||||
}
|
||||
} else if (( bvals = ldap_get_values_len( ld, entry, a )) != NULL ) {
|
||||
for ( i = 0; bvals[i] != NULL; i++ ) {
|
||||
if ( vals2tmp ) {
|
||||
#ifdef HAVE_SNPRINTF
|
||||
if ( snprintf( tmpfname, sizeof(tmpfname),
|
||||
"%s/ldapsearch-%s-XXXXXX",
|
||||
ldaptool_get_tmp_dir(), a ) < 0 ) {
|
||||
perror( "snprintf tmpfname (attribute name too long?)" );
|
||||
exit( LDAP_PARAM_ERROR );
|
||||
}
|
||||
#else
|
||||
sprintf( tmpfname, "%s/ldapsearch-%s-XXXXXX",
|
||||
ldaptool_get_tmp_dir(), a );
|
||||
#endif
|
||||
tmpfp = NULL;
|
||||
|
||||
if ( mktemp( tmpfname ) == NULL ) {
|
||||
perror( tmpfname );
|
||||
} else if (( tmpfp = fopen( tmpfname, mode)) == NULL ) {
|
||||
perror( tmpfname );
|
||||
} else if ( bvals[ i ]->bv_len > 0 &&
|
||||
fwrite( bvals[ i ]->bv_val,
|
||||
bvals[ i ]->bv_len, 1, tmpfp ) == 0 ) {
|
||||
perror( tmpfname );
|
||||
} else if ( ldif ) {
|
||||
if ( produce_file_urls ) {
|
||||
char *url;
|
||||
|
||||
if ( ldaptool_path2fileurl( tmpfname, &url ) !=
|
||||
LDAPTOOL_FILEURL_SUCCESS ) {
|
||||
perror( "ldaptool_path2fileurl" );
|
||||
} else {
|
||||
write_ldif_value( a, url, strlen( url ),
|
||||
LDIF_OPT_VALUE_IS_URL );
|
||||
free( url );
|
||||
}
|
||||
} else {
|
||||
write_ldif_value( a, tmpfname, strlen( tmpfname ),
|
||||
0 );
|
||||
}
|
||||
} else {
|
||||
printf( "%s%s%s\n", a, sep, tmpfname );
|
||||
}
|
||||
|
||||
if ( tmpfp != NULL ) {
|
||||
fclose( tmpfp );
|
||||
}
|
||||
} else {
|
||||
notascii = 0;
|
||||
if ( !ldif && !allow_binary ) {
|
||||
unsigned long j;
|
||||
|
||||
for ( j = 0; j < bvals[ i ]->bv_len; ++j ) {
|
||||
if ( !isascii( bvals[ i ]->bv_val[ j ] )) {
|
||||
notascii = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ldif ) {
|
||||
write_ldif_value( a, bvals[ i ]->bv_val,
|
||||
bvals[ i ]->bv_len, 0 );
|
||||
} else {
|
||||
printf( "%s%s%s\n", a, sep,
|
||||
notascii ? "NOT ASCII" : bvals[ i ]->bv_val );
|
||||
}
|
||||
}
|
||||
}
|
||||
ber_bvecfree( bvals );
|
||||
}
|
||||
ldap_memfree( a );
|
||||
}
|
||||
|
||||
if ( ldap_get_lderrno( ld, NULL, NULL ) != LDAP_SUCCESS ) {
|
||||
ldaptool_print_lderror( ld, "ldap_first_attribute/ldap_next_attribute",
|
||||
LDAPTOOL_CHECK4SSL_IF_APPROP );
|
||||
}
|
||||
|
||||
if ( ber != NULL ) {
|
||||
ber_free( ber, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
write_ldif_value( char *type, char *value, unsigned long vallen,
|
||||
unsigned long ldifoptions )
|
||||
{
|
||||
char *ldif;
|
||||
static int wrote_version = 0;
|
||||
|
||||
if ( write_ldif_version && !wrote_version ) {
|
||||
char versionbuf[ 64 ];
|
||||
|
||||
wrote_version = 1;
|
||||
sprintf( versionbuf, "%d", LDIF_VERSION_ONE );
|
||||
write_ldif_value( "version", versionbuf, strlen( versionbuf ), 0 );
|
||||
}
|
||||
|
||||
if ( !fold ) {
|
||||
ldifoptions |= LDIF_OPT_NOWRAP;
|
||||
}
|
||||
if ( minimize_base64 ) {
|
||||
ldifoptions |= LDIF_OPT_MINIMAL_ENCODING;
|
||||
}
|
||||
|
||||
if (( ldif = ldif_type_and_value_with_options( type, value, (int)vallen,
|
||||
ldifoptions )) == NULL ) {
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
fputs( ldif, stdout );
|
||||
free( ldif );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
sortresult2string(unsigned long result)
|
||||
{
|
||||
/*
|
||||
success (0), -- results are sorted
|
||||
operationsError (1), -- server internal failure
|
||||
timeLimitExceeded (3), -- timelimit reached before
|
||||
-- sorting was completed
|
||||
strongAuthRequired (8), -- refused to return sorted
|
||||
-- results via insecure
|
||||
-- protocol
|
||||
adminLimitExceeded (11), -- too many matching entries
|
||||
-- for the server to sort
|
||||
noSuchAttribute (16), -- unrecognized attribute
|
||||
-- type in sort key
|
||||
inappropriateMatching (18), -- unrecognized or inappro-
|
||||
-- priate matching rule in
|
||||
-- sort key
|
||||
insufficientAccessRights (50), -- refused to return sorted
|
||||
-- results to this client
|
||||
busy (51), -- too busy to process
|
||||
unwillingToPerform (53), -- unable to sort
|
||||
other (80)
|
||||
*/
|
||||
|
||||
switch (result) {
|
||||
case 0: return ("success");
|
||||
case 1: return ("operations error");
|
||||
case 3: return ("time limit exceeded");
|
||||
case 8: return ("strong auth required");
|
||||
case 11: return ("admin limit exceeded");
|
||||
case 16: return ("no such attribute");
|
||||
case 18: return ("unrecognized or inappropriate matching rule");
|
||||
case 50: return ("insufficient access rights");
|
||||
case 51: return ("too busy");
|
||||
case 53: return ("unable to sort");
|
||||
case 80:
|
||||
default: return ("Er...Other ?");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
parse_and_display_reference( LDAP *ld, LDAPMessage *ref )
|
||||
{
|
||||
int i;
|
||||
char **refs;
|
||||
|
||||
if ( ldap_parse_reference( ld, ref, &refs, NULL, 0 ) != LDAP_SUCCESS ) {
|
||||
ldaptool_print_lderror( ld, "ldap_parse_reference",
|
||||
LDAPTOOL_CHECK4SSL_IF_APPROP );
|
||||
} else if ( refs != NULL && refs[ 0 ] != NULL ) {
|
||||
fputs( "Unfollowed continuation reference(s):\n", stderr );
|
||||
for ( i = 0; refs[ i ] != NULL; ++i ) {
|
||||
fprintf( stderr, " %s\n", refs[ i ] );
|
||||
}
|
||||
ldap_value_free( refs );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*possible operations a client can invoke -- copied from ldaprot.h */
|
||||
|
||||
#ifndef LDAP_REQ_BIND
|
||||
#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_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 */
|
||||
#endif /* LDAP_REQ_BIND */
|
||||
|
||||
|
||||
|
||||
struct ldapsearch_type2str {
|
||||
|
||||
int ldst2s_type; /* message type */
|
||||
char *ldst2s_string; /* descriptive string */
|
||||
};
|
||||
|
||||
|
||||
static struct ldapsearch_type2str ldapsearch_msgtypes[] = {
|
||||
|
||||
/* results: */
|
||||
{ LDAP_RES_BIND, "bind result" },
|
||||
{ LDAP_RES_SEARCH_REFERENCE, "continuation reference" },
|
||||
{ LDAP_RES_SEARCH_ENTRY, "entry" },
|
||||
{ LDAP_RES_SEARCH_RESULT, "search result" },
|
||||
{ LDAP_RES_MODIFY, "modify result" },
|
||||
{ LDAP_RES_ADD, "add result" },
|
||||
{ LDAP_RES_DELETE, "delete result" },
|
||||
{ LDAP_RES_MODDN, "rename result" },
|
||||
{ LDAP_RES_COMPARE, "compare result" },
|
||||
{ LDAP_RES_EXTENDED, "extended operation result" },
|
||||
/* requests: */
|
||||
{ LDAP_REQ_BIND, "bind request" },
|
||||
{ LDAP_REQ_UNBIND, "unbind request" },
|
||||
{ LDAP_REQ_SEARCH, "search request" },
|
||||
{ LDAP_REQ_MODIFY, "modify request" },
|
||||
{ LDAP_REQ_ADD, "add request" },
|
||||
{ LDAP_REQ_DELETE, "delete request" },
|
||||
{ LDAP_REQ_RENAME, "rename request" },
|
||||
{ LDAP_REQ_COMPARE, "compare request" },
|
||||
{ LDAP_REQ_ABANDON, "abandon request" },
|
||||
{ LDAP_REQ_EXTENDED, "extended request" },
|
||||
|
||||
};
|
||||
|
||||
|
||||
#define LDAPSEARCHTOOL_NUMTYPES (sizeof(ldapsearch_msgtypes) \
|
||||
/ sizeof(struct ldapsearch_type2str))
|
||||
|
||||
|
||||
/*
|
||||
* Return a descriptive string given an LDAP result message type (tag).
|
||||
*/
|
||||
static char *
|
||||
msgtype2str( int msgtype )
|
||||
{
|
||||
char *s = "unknown";
|
||||
int i;
|
||||
|
||||
s = "unknown";
|
||||
for ( i = 0; i < LDAPSEARCHTOOL_NUMTYPES; ++i ) {
|
||||
if ( msgtype == ldapsearch_msgtypes[ i ].ldst2s_type ) {
|
||||
s = ldapsearch_msgtypes[ i ].ldst2s_string;
|
||||
}
|
||||
}
|
||||
return( s );
|
||||
}
|
||||
130
mozilla/directory/c-sdk/ldap/clients/tools/ldaptool.h
Normal file
130
mozilla/directory/c-sdk/ldap/clients/tools/ldaptool.h
Normal file
@@ -0,0 +1,130 @@
|
||||
#ifndef _LDAPTOOL_H
|
||||
#define _LDAPTOOL_H
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef AIX
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef SCOOS
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
extern int getopt (int argc, char *const *argv, const char *optstring);
|
||||
#else
|
||||
#include <sys/file.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef SCOOS
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#if defined(NET_SSL)
|
||||
#include <ssl.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <portable.h>
|
||||
|
||||
#include <ldap.h>
|
||||
#ifndef NO_LIBLCACHE
|
||||
#include <lcache.h>
|
||||
#endif
|
||||
|
||||
#include <ldaplog.h>
|
||||
#include <ldif.h>
|
||||
|
||||
#if defined(NET_SSL)
|
||||
#include <ldap_ssl.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* shared macros, structures, etc.
|
||||
*/
|
||||
#define LDAPTOOL_DEFSEP "=" /* used by ldapcmp and ldapsearch */
|
||||
#define LDAPTOOL_DEFHOST "localhost"
|
||||
|
||||
#define LDAPTOOL_SAFEREALLOC( ptr, size ) ( ptr == NULL ? malloc( size ) : \
|
||||
realloc( ptr, size ))
|
||||
/* this defines the max number of control requests for the tools */
|
||||
#define CONTROL_REQUESTS 5
|
||||
|
||||
/*
|
||||
* globals (defined in common.c)
|
||||
*/
|
||||
extern char *ldaptool_host;
|
||||
extern char *ldaptool_host2;
|
||||
extern int ldaptool_port;
|
||||
extern int ldaptool_port2;
|
||||
extern int ldaptool_verbose;
|
||||
extern int ldaptool_not;
|
||||
extern char *ldaptool_progname;
|
||||
extern FILE *ldaptool_fp;
|
||||
extern char *ldaptool_charset;
|
||||
extern char *ldaptool_convdir;
|
||||
extern LDAPControl *ldaptool_request_ctrls[];
|
||||
|
||||
|
||||
/*
|
||||
* function prototypes
|
||||
*/
|
||||
void ldaptool_common_usage( int two_hosts );
|
||||
int ldaptool_process_args( int argc, char **argv, char *extra_opts,
|
||||
int two_hosts, void (*extra_opt_callback)( int option, char *optarg ));
|
||||
LDAP *ldaptool_ldap_init( int second_host );
|
||||
void ldaptool_bind( LDAP *ld );
|
||||
void ldaptool_cleanup( LDAP *ld );
|
||||
int ldaptool_print_lderror( LDAP *ld, char *msg, int check4ssl );
|
||||
#define LDAPTOOL_CHECK4SSL_NEVER 0
|
||||
#define LDAPTOOL_CHECK4SSL_ALWAYS 1
|
||||
#define LDAPTOOL_CHECK4SSL_IF_APPROP 2 /* if appropriate */
|
||||
LDAPControl *ldaptool_create_manage_dsait_control( void );
|
||||
void ldaptool_print_referrals( char **refs );
|
||||
int ldaptool_print_extended_response( LDAP *ld, LDAPMessage *res, char *msg );
|
||||
LDAPControl *ldaptool_create_proxyauth_control( LDAP *ld );
|
||||
void ldaptool_add_control_to_array( LDAPControl *ctrl, LDAPControl **array);
|
||||
void ldaptool_reset_control_array( LDAPControl **array );
|
||||
char *ldaptool_get_tmp_dir( void );
|
||||
char *ldaptool_local2UTF8( const char * );
|
||||
int ldaptool_sasl_bind_s( LDAP *ld, const char *dn, const char *mechanism,
|
||||
const struct berval *cred, LDAPControl **serverctrls,
|
||||
LDAPControl **clientctrls, struct berval **servercredp, char *msg );
|
||||
int ldaptool_simple_bind_s( LDAP *ld, const char *dn, const char *passwd,
|
||||
LDAPControl **serverctrls, LDAPControl **clientctrls, char *msg );
|
||||
int ldaptool_add_ext_s( LDAP *ld, const char *dn, LDAPMod **attrs,
|
||||
LDAPControl **serverctrls, LDAPControl **clientctrls, char *msg );
|
||||
int ldaptool_modify_ext_s( LDAP *ld, const char *dn, LDAPMod **mods,
|
||||
LDAPControl **serverctrls, LDAPControl **clientctrls, char *msg );
|
||||
int ldaptool_delete_ext_s( LDAP *ld, const char *dn, LDAPControl **serverctrls,
|
||||
LDAPControl **clientctrls, char *msg );
|
||||
int ldaptool_rename_s( LDAP *ld, const char *dn, const char *newrdn,
|
||||
const char *newparent, int deleteoldrdn, LDAPControl **serverctrls,
|
||||
LDAPControl **clientctrls, char *msg );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LDAPTOOL_H */
|
||||
97
mozilla/directory/c-sdk/ldap/clients/tools/ntuserpin.c
Normal file
97
mozilla/directory/c-sdk/ldap/clients/tools/ntuserpin.c
Normal file
@@ -0,0 +1,97 @@
|
||||
/******************************************************
|
||||
*
|
||||
* Copyright (c) 1996 Netscape Communications Corp.
|
||||
* This code is proprietary and is a trade secret of
|
||||
* Netscape Communications Corp.
|
||||
*
|
||||
* ntuserpin.c - Prompts for the key
|
||||
* database passphrase.
|
||||
*
|
||||
******************************************************/
|
||||
|
||||
#if defined( _WIN32 ) && defined ( NET_SSL )
|
||||
|
||||
#include <conio.h>
|
||||
#include "ntuserpin.h"
|
||||
|
||||
#undef Debug
|
||||
#undef OFF
|
||||
#undef LITTLE_ENDIAN
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
static int i=0;
|
||||
static int cbRemotePassword = 0;
|
||||
static const char nt_retryWarning[] =
|
||||
"Warning: You entered an incorrect PIN.\nIncorrect PIN may result in disabling the token";
|
||||
static const char prompt[] = "Enter PIN for";
|
||||
|
||||
|
||||
#define SZ_LOCAL_PWD 1024
|
||||
static char loclpwd[SZ_LOCAL_PWD] = "";
|
||||
struct SVRCORENTUserPinObj
|
||||
{
|
||||
SVRCOREPinObj base;
|
||||
};
|
||||
static const struct SVRCOREPinMethods vtable;
|
||||
/* ------------------------------------------------------------ */
|
||||
SVRCOREError
|
||||
SVRCORE_CreateNTUserPinObj(SVRCORENTUserPinObj **out)
|
||||
{
|
||||
SVRCOREError err = 0;
|
||||
SVRCORENTUserPinObj *obj = 0;
|
||||
do {
|
||||
obj = (SVRCORENTUserPinObj*)malloc(sizeof (SVRCORENTUserPinObj));
|
||||
if (!obj) { err = 1; break; }
|
||||
obj->base.methods = &vtable;
|
||||
} while(0);
|
||||
if (err)
|
||||
{
|
||||
SVRCORE_DestroyNTUserPinObj(obj);
|
||||
obj = 0;
|
||||
}
|
||||
*out = obj;
|
||||
return err;
|
||||
}
|
||||
void
|
||||
SVRCORE_DestroyNTUserPinObj(SVRCORENTUserPinObj *obj)
|
||||
{
|
||||
if (obj) free(obj);
|
||||
}
|
||||
static void destroyObject(SVRCOREPinObj *obj)
|
||||
{
|
||||
SVRCORE_DestroyNTUserPinObj((SVRCORENTUserPinObj*)obj);
|
||||
}
|
||||
static char *getPin(SVRCOREPinObj *obj, const char *tokenName, PRBool retry)
|
||||
{
|
||||
char *pwd;
|
||||
int ch;
|
||||
if (retry)
|
||||
printf("%s\n",nt_retryWarning);
|
||||
printf("%s %s:", prompt, tokenName);
|
||||
pwd = &loclpwd[0];
|
||||
do
|
||||
{
|
||||
ch = _getch();
|
||||
*pwd++ = (char )ch;
|
||||
} while( ch != '\r' && (pwd < &loclpwd[SZ_LOCAL_PWD - 1]));
|
||||
*(pwd-1)='\0';
|
||||
printf("\n");
|
||||
|
||||
/* test for zero length password. if zero length, return null */
|
||||
if ('\0' == loclpwd[0])
|
||||
return NULL;
|
||||
|
||||
return &loclpwd[0];
|
||||
}
|
||||
|
||||
/*
|
||||
* VTable
|
||||
*/
|
||||
static const SVRCOREPinMethods vtable =
|
||||
{ 0, 0, destroyObject, getPin };
|
||||
#endif /* defined( _WIN32 ) && defined ( NET_SSL ) */
|
||||
|
||||
25
mozilla/directory/c-sdk/ldap/clients/tools/ntuserpin.h
Normal file
25
mozilla/directory/c-sdk/ldap/clients/tools/ntuserpin.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/******************************************************
|
||||
*
|
||||
* Copyright (c) 1996 Netscape Communications Corp.
|
||||
* This code is proprietary and is a trade secret of
|
||||
* Netscape Communications Corp.
|
||||
*
|
||||
* ntuserpin.h - Prompts for the key
|
||||
* database passphrase.
|
||||
*
|
||||
******************************************************/
|
||||
#ifndef _NTUSERPIN_H_
|
||||
#define _NTUSERPIN_H_
|
||||
#include "svrcore.h"
|
||||
|
||||
typedef struct SVRCORENTUserPinObj SVRCORENTUserPinObj;
|
||||
|
||||
SVRCOREError
|
||||
SVRCORE_CreateNTUserPinObj(SVRCORENTUserPinObj **out);
|
||||
|
||||
void
|
||||
SVRCORE_SetNTUserPinInteractive(SVRCORENTUserPinObj *obj, PRBool interactive);
|
||||
|
||||
void
|
||||
SVRCORE_DestroyNTUserPinObj(SVRCORENTUserPinObj *obj);
|
||||
#endif
|
||||
1812
mozilla/directory/c-sdk/ldap/clients/tools/tools.mak
Normal file
1812
mozilla/directory/c-sdk/ldap/clients/tools/tools.mak
Normal file
File diff suppressed because it is too large
Load Diff
798
mozilla/directory/c-sdk/ldap/configure
vendored
Executable file
798
mozilla/directory/c-sdk/ldap/configure
vendored
Executable file
@@ -0,0 +1,798 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated automatically using autoconf version 2.13
|
||||
# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
|
||||
#
|
||||
# This configure script is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy, distribute and modify it.
|
||||
|
||||
# Defaults:
|
||||
ac_help=
|
||||
ac_default_prefix=/usr/local
|
||||
# Any additions from configure.in:
|
||||
ac_help="$ac_help
|
||||
--enable-nspr-autoconf Enable building with an autoconf'ed NSPR tree"
|
||||
|
||||
# Initialize some variables set by options.
|
||||
# The variables have the same names as the options, with
|
||||
# dashes changed to underlines.
|
||||
build=NONE
|
||||
cache_file=./config.cache
|
||||
exec_prefix=NONE
|
||||
host=NONE
|
||||
no_create=
|
||||
nonopt=NONE
|
||||
no_recursion=
|
||||
prefix=NONE
|
||||
program_prefix=NONE
|
||||
program_suffix=NONE
|
||||
program_transform_name=s,x,x,
|
||||
silent=
|
||||
site=
|
||||
srcdir=
|
||||
target=NONE
|
||||
verbose=
|
||||
x_includes=NONE
|
||||
x_libraries=NONE
|
||||
bindir='${exec_prefix}/bin'
|
||||
sbindir='${exec_prefix}/sbin'
|
||||
libexecdir='${exec_prefix}/libexec'
|
||||
datadir='${prefix}/share'
|
||||
sysconfdir='${prefix}/etc'
|
||||
sharedstatedir='${prefix}/com'
|
||||
localstatedir='${prefix}/var'
|
||||
libdir='${exec_prefix}/lib'
|
||||
includedir='${prefix}/include'
|
||||
oldincludedir='/usr/include'
|
||||
infodir='${prefix}/info'
|
||||
mandir='${prefix}/man'
|
||||
|
||||
# Initialize some other variables.
|
||||
subdirs=
|
||||
MFLAGS= MAKEFLAGS=
|
||||
SHELL=${CONFIG_SHELL-/bin/sh}
|
||||
# Maximum number of lines to put in a shell here document.
|
||||
ac_max_here_lines=12
|
||||
|
||||
ac_prev=
|
||||
for ac_option
|
||||
do
|
||||
|
||||
# If the previous option needs an argument, assign it.
|
||||
if test -n "$ac_prev"; then
|
||||
eval "$ac_prev=\$ac_option"
|
||||
ac_prev=
|
||||
continue
|
||||
fi
|
||||
|
||||
case "$ac_option" in
|
||||
-*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
|
||||
*) ac_optarg= ;;
|
||||
esac
|
||||
|
||||
# Accept the important Cygnus configure options, so we can diagnose typos.
|
||||
|
||||
case "$ac_option" in
|
||||
|
||||
-bindir | --bindir | --bindi | --bind | --bin | --bi)
|
||||
ac_prev=bindir ;;
|
||||
-bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
|
||||
bindir="$ac_optarg" ;;
|
||||
|
||||
-build | --build | --buil | --bui | --bu)
|
||||
ac_prev=build ;;
|
||||
-build=* | --build=* | --buil=* | --bui=* | --bu=*)
|
||||
build="$ac_optarg" ;;
|
||||
|
||||
-cache-file | --cache-file | --cache-fil | --cache-fi \
|
||||
| --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
|
||||
ac_prev=cache_file ;;
|
||||
-cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
|
||||
| --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
|
||||
cache_file="$ac_optarg" ;;
|
||||
|
||||
-datadir | --datadir | --datadi | --datad | --data | --dat | --da)
|
||||
ac_prev=datadir ;;
|
||||
-datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
|
||||
| --da=*)
|
||||
datadir="$ac_optarg" ;;
|
||||
|
||||
-disable-* | --disable-*)
|
||||
ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
|
||||
# Reject names that are not valid shell variable names.
|
||||
if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
|
||||
{ echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
|
||||
fi
|
||||
ac_feature=`echo $ac_feature| sed 's/-/_/g'`
|
||||
eval "enable_${ac_feature}=no" ;;
|
||||
|
||||
-enable-* | --enable-*)
|
||||
ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
|
||||
# Reject names that are not valid shell variable names.
|
||||
if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
|
||||
{ echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
|
||||
fi
|
||||
ac_feature=`echo $ac_feature| sed 's/-/_/g'`
|
||||
case "$ac_option" in
|
||||
*=*) ;;
|
||||
*) ac_optarg=yes ;;
|
||||
esac
|
||||
eval "enable_${ac_feature}='$ac_optarg'" ;;
|
||||
|
||||
-exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
|
||||
| --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
|
||||
| --exec | --exe | --ex)
|
||||
ac_prev=exec_prefix ;;
|
||||
-exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
|
||||
| --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
|
||||
| --exec=* | --exe=* | --ex=*)
|
||||
exec_prefix="$ac_optarg" ;;
|
||||
|
||||
-gas | --gas | --ga | --g)
|
||||
# Obsolete; use --with-gas.
|
||||
with_gas=yes ;;
|
||||
|
||||
-help | --help | --hel | --he)
|
||||
# Omit some internal or obsolete options to make the list less imposing.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
cat << EOF
|
||||
Usage: configure [options] [host]
|
||||
Options: [defaults in brackets after descriptions]
|
||||
Configuration:
|
||||
--cache-file=FILE cache test results in FILE
|
||||
--help print this message
|
||||
--no-create do not create output files
|
||||
--quiet, --silent do not print \`checking...' messages
|
||||
--version print the version of autoconf that created configure
|
||||
Directory and file names:
|
||||
--prefix=PREFIX install architecture-independent files in PREFIX
|
||||
[$ac_default_prefix]
|
||||
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
|
||||
[same as prefix]
|
||||
--bindir=DIR user executables in DIR [EPREFIX/bin]
|
||||
--sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
|
||||
--libexecdir=DIR program executables in DIR [EPREFIX/libexec]
|
||||
--datadir=DIR read-only architecture-independent data in DIR
|
||||
[PREFIX/share]
|
||||
--sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
|
||||
--sharedstatedir=DIR modifiable architecture-independent data in DIR
|
||||
[PREFIX/com]
|
||||
--localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
|
||||
--libdir=DIR object code libraries in DIR [EPREFIX/lib]
|
||||
--includedir=DIR C header files in DIR [PREFIX/include]
|
||||
--oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
|
||||
--infodir=DIR info documentation in DIR [PREFIX/info]
|
||||
--mandir=DIR man documentation in DIR [PREFIX/man]
|
||||
--srcdir=DIR find the sources in DIR [configure dir or ..]
|
||||
--program-prefix=PREFIX prepend PREFIX to installed program names
|
||||
--program-suffix=SUFFIX append SUFFIX to installed program names
|
||||
--program-transform-name=PROGRAM
|
||||
run sed PROGRAM on installed program names
|
||||
EOF
|
||||
cat << EOF
|
||||
Host type:
|
||||
--build=BUILD configure for building on BUILD [BUILD=HOST]
|
||||
--host=HOST configure for HOST [guessed]
|
||||
--target=TARGET configure for TARGET [TARGET=HOST]
|
||||
Features and packages:
|
||||
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
|
||||
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
|
||||
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
|
||||
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
|
||||
--x-includes=DIR X include files are in DIR
|
||||
--x-libraries=DIR X library files are in DIR
|
||||
EOF
|
||||
if test -n "$ac_help"; then
|
||||
echo "--enable and --with options recognized:$ac_help"
|
||||
fi
|
||||
exit 0 ;;
|
||||
|
||||
-host | --host | --hos | --ho)
|
||||
ac_prev=host ;;
|
||||
-host=* | --host=* | --hos=* | --ho=*)
|
||||
host="$ac_optarg" ;;
|
||||
|
||||
-includedir | --includedir | --includedi | --included | --include \
|
||||
| --includ | --inclu | --incl | --inc)
|
||||
ac_prev=includedir ;;
|
||||
-includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
|
||||
| --includ=* | --inclu=* | --incl=* | --inc=*)
|
||||
includedir="$ac_optarg" ;;
|
||||
|
||||
-infodir | --infodir | --infodi | --infod | --info | --inf)
|
||||
ac_prev=infodir ;;
|
||||
-infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
|
||||
infodir="$ac_optarg" ;;
|
||||
|
||||
-libdir | --libdir | --libdi | --libd)
|
||||
ac_prev=libdir ;;
|
||||
-libdir=* | --libdir=* | --libdi=* | --libd=*)
|
||||
libdir="$ac_optarg" ;;
|
||||
|
||||
-libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
|
||||
| --libexe | --libex | --libe)
|
||||
ac_prev=libexecdir ;;
|
||||
-libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
|
||||
| --libexe=* | --libex=* | --libe=*)
|
||||
libexecdir="$ac_optarg" ;;
|
||||
|
||||
-localstatedir | --localstatedir | --localstatedi | --localstated \
|
||||
| --localstate | --localstat | --localsta | --localst \
|
||||
| --locals | --local | --loca | --loc | --lo)
|
||||
ac_prev=localstatedir ;;
|
||||
-localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
|
||||
| --localstate=* | --localstat=* | --localsta=* | --localst=* \
|
||||
| --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
|
||||
localstatedir="$ac_optarg" ;;
|
||||
|
||||
-mandir | --mandir | --mandi | --mand | --man | --ma | --m)
|
||||
ac_prev=mandir ;;
|
||||
-mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
|
||||
mandir="$ac_optarg" ;;
|
||||
|
||||
-nfp | --nfp | --nf)
|
||||
# Obsolete; use --without-fp.
|
||||
with_fp=no ;;
|
||||
|
||||
-no-create | --no-create | --no-creat | --no-crea | --no-cre \
|
||||
| --no-cr | --no-c)
|
||||
no_create=yes ;;
|
||||
|
||||
-no-recursion | --no-recursion | --no-recursio | --no-recursi \
|
||||
| --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
|
||||
no_recursion=yes ;;
|
||||
|
||||
-oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
|
||||
| --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
|
||||
| --oldin | --oldi | --old | --ol | --o)
|
||||
ac_prev=oldincludedir ;;
|
||||
-oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
|
||||
| --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
|
||||
| --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
|
||||
oldincludedir="$ac_optarg" ;;
|
||||
|
||||
-prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
|
||||
ac_prev=prefix ;;
|
||||
-prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
|
||||
prefix="$ac_optarg" ;;
|
||||
|
||||
-program-prefix | --program-prefix | --program-prefi | --program-pref \
|
||||
| --program-pre | --program-pr | --program-p)
|
||||
ac_prev=program_prefix ;;
|
||||
-program-prefix=* | --program-prefix=* | --program-prefi=* \
|
||||
| --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
|
||||
program_prefix="$ac_optarg" ;;
|
||||
|
||||
-program-suffix | --program-suffix | --program-suffi | --program-suff \
|
||||
| --program-suf | --program-su | --program-s)
|
||||
ac_prev=program_suffix ;;
|
||||
-program-suffix=* | --program-suffix=* | --program-suffi=* \
|
||||
| --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
|
||||
program_suffix="$ac_optarg" ;;
|
||||
|
||||
-program-transform-name | --program-transform-name \
|
||||
| --program-transform-nam | --program-transform-na \
|
||||
| --program-transform-n | --program-transform- \
|
||||
| --program-transform | --program-transfor \
|
||||
| --program-transfo | --program-transf \
|
||||
| --program-trans | --program-tran \
|
||||
| --progr-tra | --program-tr | --program-t)
|
||||
ac_prev=program_transform_name ;;
|
||||
-program-transform-name=* | --program-transform-name=* \
|
||||
| --program-transform-nam=* | --program-transform-na=* \
|
||||
| --program-transform-n=* | --program-transform-=* \
|
||||
| --program-transform=* | --program-transfor=* \
|
||||
| --program-transfo=* | --program-transf=* \
|
||||
| --program-trans=* | --program-tran=* \
|
||||
| --progr-tra=* | --program-tr=* | --program-t=*)
|
||||
program_transform_name="$ac_optarg" ;;
|
||||
|
||||
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
|
||||
| -silent | --silent | --silen | --sile | --sil)
|
||||
silent=yes ;;
|
||||
|
||||
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
|
||||
ac_prev=sbindir ;;
|
||||
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
|
||||
| --sbi=* | --sb=*)
|
||||
sbindir="$ac_optarg" ;;
|
||||
|
||||
-sharedstatedir | --sharedstatedir | --sharedstatedi \
|
||||
| --sharedstated | --sharedstate | --sharedstat | --sharedsta \
|
||||
| --sharedst | --shareds | --shared | --share | --shar \
|
||||
| --sha | --sh)
|
||||
ac_prev=sharedstatedir ;;
|
||||
-sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
|
||||
| --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
|
||||
| --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
|
||||
| --sha=* | --sh=*)
|
||||
sharedstatedir="$ac_optarg" ;;
|
||||
|
||||
-site | --site | --sit)
|
||||
ac_prev=site ;;
|
||||
-site=* | --site=* | --sit=*)
|
||||
site="$ac_optarg" ;;
|
||||
|
||||
-srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
|
||||
ac_prev=srcdir ;;
|
||||
-srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
|
||||
srcdir="$ac_optarg" ;;
|
||||
|
||||
-sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
|
||||
| --syscon | --sysco | --sysc | --sys | --sy)
|
||||
ac_prev=sysconfdir ;;
|
||||
-sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
|
||||
| --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
|
||||
sysconfdir="$ac_optarg" ;;
|
||||
|
||||
-target | --target | --targe | --targ | --tar | --ta | --t)
|
||||
ac_prev=target ;;
|
||||
-target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
|
||||
target="$ac_optarg" ;;
|
||||
|
||||
-v | -verbose | --verbose | --verbos | --verbo | --verb)
|
||||
verbose=yes ;;
|
||||
|
||||
-version | --version | --versio | --versi | --vers)
|
||||
echo "configure generated by autoconf version 2.13"
|
||||
exit 0 ;;
|
||||
|
||||
-with-* | --with-*)
|
||||
ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
|
||||
# Reject names that are not valid shell variable names.
|
||||
if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
|
||||
{ echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
|
||||
fi
|
||||
ac_package=`echo $ac_package| sed 's/-/_/g'`
|
||||
case "$ac_option" in
|
||||
*=*) ;;
|
||||
*) ac_optarg=yes ;;
|
||||
esac
|
||||
eval "with_${ac_package}='$ac_optarg'" ;;
|
||||
|
||||
-without-* | --without-*)
|
||||
ac_package=`echo $ac_option|sed -e 's/-*without-//'`
|
||||
# Reject names that are not valid shell variable names.
|
||||
if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
|
||||
{ echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
|
||||
fi
|
||||
ac_package=`echo $ac_package| sed 's/-/_/g'`
|
||||
eval "with_${ac_package}=no" ;;
|
||||
|
||||
--x)
|
||||
# Obsolete; use --with-x.
|
||||
with_x=yes ;;
|
||||
|
||||
-x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
|
||||
| --x-incl | --x-inc | --x-in | --x-i)
|
||||
ac_prev=x_includes ;;
|
||||
-x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
|
||||
| --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
|
||||
x_includes="$ac_optarg" ;;
|
||||
|
||||
-x-libraries | --x-libraries | --x-librarie | --x-librari \
|
||||
| --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
|
||||
ac_prev=x_libraries ;;
|
||||
-x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
|
||||
| --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
|
||||
x_libraries="$ac_optarg" ;;
|
||||
|
||||
-*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
|
||||
;;
|
||||
|
||||
*)
|
||||
if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
|
||||
echo "configure: warning: $ac_option: invalid host type" 1>&2
|
||||
fi
|
||||
if test "x$nonopt" != xNONE; then
|
||||
{ echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
|
||||
fi
|
||||
nonopt="$ac_option"
|
||||
;;
|
||||
|
||||
esac
|
||||
done
|
||||
|
||||
if test -n "$ac_prev"; then
|
||||
{ echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
|
||||
fi
|
||||
|
||||
trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
|
||||
|
||||
# File descriptor usage:
|
||||
# 0 standard input
|
||||
# 1 file creation
|
||||
# 2 errors and warnings
|
||||
# 3 some systems may open it to /dev/tty
|
||||
# 4 used on the Kubota Titan
|
||||
# 6 checking for... messages and results
|
||||
# 5 compiler messages saved in config.log
|
||||
if test "$silent" = yes; then
|
||||
exec 6>/dev/null
|
||||
else
|
||||
exec 6>&1
|
||||
fi
|
||||
exec 5>./config.log
|
||||
|
||||
echo "\
|
||||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
" 1>&5
|
||||
|
||||
# Strip out --no-create and --no-recursion so they do not pile up.
|
||||
# Also quote any args containing shell metacharacters.
|
||||
ac_configure_args=
|
||||
for ac_arg
|
||||
do
|
||||
case "$ac_arg" in
|
||||
-no-create | --no-create | --no-creat | --no-crea | --no-cre \
|
||||
| --no-cr | --no-c) ;;
|
||||
-no-recursion | --no-recursion | --no-recursio | --no-recursi \
|
||||
| --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
|
||||
*" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
|
||||
ac_configure_args="$ac_configure_args '$ac_arg'" ;;
|
||||
*) ac_configure_args="$ac_configure_args $ac_arg" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# NLS nuisances.
|
||||
# Only set these to C if already set. These must not be set unconditionally
|
||||
# because not all systems understand e.g. LANG=C (notably SCO).
|
||||
# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
|
||||
# Non-C LC_CTYPE values break the ctype check.
|
||||
if test "${LANG+set}" = set; then LANG=C; export LANG; fi
|
||||
if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
|
||||
if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
|
||||
if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
|
||||
|
||||
# confdefs.h avoids OS command line length limits that DEFS can exceed.
|
||||
rm -rf conftest* confdefs.h
|
||||
# AIX cpp loses on an empty file, so make sure it contains at least a newline.
|
||||
echo > confdefs.h
|
||||
|
||||
# A filename unique to this package, relative to the directory that
|
||||
# configure is in, which we can look for to find out if srcdir is correct.
|
||||
ac_unique_file=build/dirver.c
|
||||
|
||||
# Find the source files, if location was not specified.
|
||||
if test -z "$srcdir"; then
|
||||
ac_srcdir_defaulted=yes
|
||||
# Try the directory containing this script, then its parent.
|
||||
ac_prog=$0
|
||||
ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
|
||||
test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
|
||||
srcdir=$ac_confdir
|
||||
if test ! -r $srcdir/$ac_unique_file; then
|
||||
srcdir=..
|
||||
fi
|
||||
else
|
||||
ac_srcdir_defaulted=no
|
||||
fi
|
||||
if test ! -r $srcdir/$ac_unique_file; then
|
||||
if test "$ac_srcdir_defaulted" = yes; then
|
||||
{ echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
|
||||
else
|
||||
{ echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
|
||||
fi
|
||||
fi
|
||||
srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
|
||||
|
||||
# Prefer explicitly selected file to automatically selected ones.
|
||||
if test -z "$CONFIG_SITE"; then
|
||||
if test "x$prefix" != xNONE; then
|
||||
CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
|
||||
else
|
||||
CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
|
||||
fi
|
||||
fi
|
||||
for ac_site_file in $CONFIG_SITE; do
|
||||
if test -r "$ac_site_file"; then
|
||||
echo "loading site script $ac_site_file"
|
||||
. "$ac_site_file"
|
||||
fi
|
||||
done
|
||||
|
||||
if test -r "$cache_file"; then
|
||||
echo "loading cache $cache_file"
|
||||
. $cache_file
|
||||
else
|
||||
echo "creating cache $cache_file"
|
||||
> $cache_file
|
||||
fi
|
||||
|
||||
ac_ext=c
|
||||
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
|
||||
ac_cpp='$CPP $CPPFLAGS'
|
||||
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
|
||||
ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
|
||||
cross_compiling=$ac_cv_prog_cc_cross
|
||||
|
||||
ac_exeext=
|
||||
ac_objext=o
|
||||
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
|
||||
# Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
|
||||
if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
|
||||
ac_n= ac_c='
|
||||
' ac_t=' '
|
||||
else
|
||||
ac_n=-n ac_c= ac_t=
|
||||
fi
|
||||
else
|
||||
ac_n= ac_c='\c' ac_t=
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# Check whether --enable-nspr-autoconf or --disable-nspr-autoconf was given.
|
||||
if test "${enable_nspr_autoconf+set}" = set; then
|
||||
enableval="$enable_nspr_autoconf"
|
||||
NSPR_USE_AUTOCONF=1
|
||||
else
|
||||
NSPR_USE_AUTOCONF=0
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
MAKEFILES="
|
||||
Makefile
|
||||
build/Makefile
|
||||
build/autoconf.mk
|
||||
include/Makefile
|
||||
libraries/Makefile
|
||||
libraries/libldap/Makefile
|
||||
libraries/liblber/Makefile
|
||||
"
|
||||
trap '' 1 2 15
|
||||
cat > confcache <<\EOF
|
||||
# This file is a shell script that caches the results of configure
|
||||
# tests run on this system so they can be shared between configure
|
||||
# scripts and configure runs. It is not useful on other systems.
|
||||
# If it contains results you don't want to keep, you may remove or edit it.
|
||||
#
|
||||
# By default, configure uses ./config.cache as the cache file,
|
||||
# creating it if it does not exist already. You can give configure
|
||||
# the --cache-file=FILE option to use a different cache file; that is
|
||||
# what configure does when it calls configure scripts in
|
||||
# subdirectories, so they share the cache.
|
||||
# Giving --cache-file=/dev/null disables caching, for debugging configure.
|
||||
# config.status only pays attention to the cache file if you give it the
|
||||
# --recheck option to rerun configure.
|
||||
#
|
||||
EOF
|
||||
# The following way of writing the cache mishandles newlines in values,
|
||||
# but we know of no workaround that is simple, portable, and efficient.
|
||||
# So, don't put newlines in cache variables' values.
|
||||
# Ultrix sh set writes to stderr and can't be redirected directly,
|
||||
# and sets the high bit in the cache file unless we assign to the vars.
|
||||
(set) 2>&1 |
|
||||
case `(ac_space=' '; set | grep ac_space) 2>&1` in
|
||||
*ac_space=\ *)
|
||||
# `set' does not quote correctly, so add quotes (double-quote substitution
|
||||
# turns \\\\ into \\, and sed turns \\ into \).
|
||||
sed -n \
|
||||
-e "s/'/'\\\\''/g" \
|
||||
-e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
|
||||
;;
|
||||
*)
|
||||
# `set' quotes correctly as required by POSIX, so do not add quotes.
|
||||
sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
|
||||
;;
|
||||
esac >> confcache
|
||||
if cmp -s $cache_file confcache; then
|
||||
:
|
||||
else
|
||||
if test -w $cache_file; then
|
||||
echo "updating cache $cache_file"
|
||||
cat confcache > $cache_file
|
||||
else
|
||||
echo "not updating unwritable cache $cache_file"
|
||||
fi
|
||||
fi
|
||||
rm -f confcache
|
||||
|
||||
trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
|
||||
|
||||
test "x$prefix" = xNONE && prefix=$ac_default_prefix
|
||||
# Let make expand exec_prefix.
|
||||
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
|
||||
|
||||
# Any assignment to VPATH causes Sun make to only execute
|
||||
# the first set of double-colon rules, so remove it if not needed.
|
||||
# If there is a colon in the path, we need to keep it.
|
||||
if test "x$srcdir" = x.; then
|
||||
ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
|
||||
fi
|
||||
|
||||
trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
|
||||
|
||||
# Transform confdefs.h into DEFS.
|
||||
# Protect against shell expansion while executing Makefile rules.
|
||||
# Protect against Makefile macro expansion.
|
||||
cat > conftest.defs <<\EOF
|
||||
s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
|
||||
s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g
|
||||
s%\[%\\&%g
|
||||
s%\]%\\&%g
|
||||
s%\$%$$%g
|
||||
EOF
|
||||
DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
|
||||
rm -f conftest.defs
|
||||
|
||||
|
||||
# Without the "./", some shells look in PATH for config.status.
|
||||
: ${CONFIG_STATUS=./config.status}
|
||||
|
||||
echo creating $CONFIG_STATUS
|
||||
rm -f $CONFIG_STATUS
|
||||
cat > $CONFIG_STATUS <<EOF
|
||||
#! /bin/sh
|
||||
# Generated automatically by configure.
|
||||
# Run this file to recreate the current configuration.
|
||||
# This directory was configured as follows,
|
||||
# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
|
||||
#
|
||||
# $0 $ac_configure_args
|
||||
#
|
||||
# Compiler output produced by configure, useful for debugging
|
||||
# configure, is in ./config.log if it exists.
|
||||
|
||||
ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
|
||||
for ac_option
|
||||
do
|
||||
case "\$ac_option" in
|
||||
-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
|
||||
echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
|
||||
exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
|
||||
-version | --version | --versio | --versi | --vers | --ver | --ve | --v)
|
||||
echo "$CONFIG_STATUS generated by autoconf version 2.13"
|
||||
exit 0 ;;
|
||||
-help | --help | --hel | --he | --h)
|
||||
echo "\$ac_cs_usage"; exit 0 ;;
|
||||
*) echo "\$ac_cs_usage"; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
ac_given_srcdir=$srcdir
|
||||
|
||||
trap 'rm -fr `echo "$MAKEFILES" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
|
||||
EOF
|
||||
cat >> $CONFIG_STATUS <<EOF
|
||||
|
||||
# Protect against being on the right side of a sed subst in config.status.
|
||||
sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
|
||||
s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
|
||||
$ac_vpsub
|
||||
$extrasub
|
||||
s%@SHELL@%$SHELL%g
|
||||
s%@CFLAGS@%$CFLAGS%g
|
||||
s%@CPPFLAGS@%$CPPFLAGS%g
|
||||
s%@CXXFLAGS@%$CXXFLAGS%g
|
||||
s%@FFLAGS@%$FFLAGS%g
|
||||
s%@DEFS@%$DEFS%g
|
||||
s%@LDFLAGS@%$LDFLAGS%g
|
||||
s%@LIBS@%$LIBS%g
|
||||
s%@exec_prefix@%$exec_prefix%g
|
||||
s%@prefix@%$prefix%g
|
||||
s%@program_transform_name@%$program_transform_name%g
|
||||
s%@bindir@%$bindir%g
|
||||
s%@sbindir@%$sbindir%g
|
||||
s%@libexecdir@%$libexecdir%g
|
||||
s%@datadir@%$datadir%g
|
||||
s%@sysconfdir@%$sysconfdir%g
|
||||
s%@sharedstatedir@%$sharedstatedir%g
|
||||
s%@localstatedir@%$localstatedir%g
|
||||
s%@libdir@%$libdir%g
|
||||
s%@includedir@%$includedir%g
|
||||
s%@oldincludedir@%$oldincludedir%g
|
||||
s%@infodir@%$infodir%g
|
||||
s%@mandir@%$mandir%g
|
||||
s%@NSPR_USE_AUTOCONF@%$NSPR_USE_AUTOCONF%g
|
||||
|
||||
CEOF
|
||||
EOF
|
||||
|
||||
cat >> $CONFIG_STATUS <<\EOF
|
||||
|
||||
# Split the substitutions into bite-sized pieces for seds with
|
||||
# small command number limits, like on Digital OSF/1 and HP-UX.
|
||||
ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
|
||||
ac_file=1 # Number of current file.
|
||||
ac_beg=1 # First line for current file.
|
||||
ac_end=$ac_max_sed_cmds # Line after last line for current file.
|
||||
ac_more_lines=:
|
||||
ac_sed_cmds=""
|
||||
while $ac_more_lines; do
|
||||
if test $ac_beg -gt 1; then
|
||||
sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
|
||||
else
|
||||
sed "${ac_end}q" conftest.subs > conftest.s$ac_file
|
||||
fi
|
||||
if test ! -s conftest.s$ac_file; then
|
||||
ac_more_lines=false
|
||||
rm -f conftest.s$ac_file
|
||||
else
|
||||
if test -z "$ac_sed_cmds"; then
|
||||
ac_sed_cmds="sed -f conftest.s$ac_file"
|
||||
else
|
||||
ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
|
||||
fi
|
||||
ac_file=`expr $ac_file + 1`
|
||||
ac_beg=$ac_end
|
||||
ac_end=`expr $ac_end + $ac_max_sed_cmds`
|
||||
fi
|
||||
done
|
||||
if test -z "$ac_sed_cmds"; then
|
||||
ac_sed_cmds=cat
|
||||
fi
|
||||
EOF
|
||||
|
||||
cat >> $CONFIG_STATUS <<EOF
|
||||
|
||||
CONFIG_FILES=\${CONFIG_FILES-"$MAKEFILES"}
|
||||
EOF
|
||||
cat >> $CONFIG_STATUS <<\EOF
|
||||
for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
|
||||
# Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
|
||||
case "$ac_file" in
|
||||
*:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
|
||||
ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
|
||||
*) ac_file_in="${ac_file}.in" ;;
|
||||
esac
|
||||
|
||||
# Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
|
||||
|
||||
# Remove last slash and all that follows it. Not all systems have dirname.
|
||||
ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
|
||||
if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
|
||||
# The file is in a subdirectory.
|
||||
test ! -d "$ac_dir" && mkdir "$ac_dir"
|
||||
ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
|
||||
# A "../" for each directory in $ac_dir_suffix.
|
||||
ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
|
||||
else
|
||||
ac_dir_suffix= ac_dots=
|
||||
fi
|
||||
|
||||
case "$ac_given_srcdir" in
|
||||
.) srcdir=.
|
||||
if test -z "$ac_dots"; then top_srcdir=.
|
||||
else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
|
||||
/*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
|
||||
*) # Relative path.
|
||||
srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
|
||||
top_srcdir="$ac_dots$ac_given_srcdir" ;;
|
||||
esac
|
||||
|
||||
|
||||
echo creating "$ac_file"
|
||||
rm -f "$ac_file"
|
||||
configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
|
||||
case "$ac_file" in
|
||||
*Makefile*) ac_comsub="1i\\
|
||||
# $configure_input" ;;
|
||||
*) ac_comsub= ;;
|
||||
esac
|
||||
|
||||
ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
|
||||
sed -e "$ac_comsub
|
||||
s%@configure_input@%$configure_input%g
|
||||
s%@srcdir@%$srcdir%g
|
||||
s%@top_srcdir@%$top_srcdir%g
|
||||
" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
|
||||
fi; done
|
||||
rm -f conftest.s*
|
||||
|
||||
EOF
|
||||
cat >> $CONFIG_STATUS <<EOF
|
||||
|
||||
EOF
|
||||
cat >> $CONFIG_STATUS <<\EOF
|
||||
|
||||
exit 0
|
||||
EOF
|
||||
chmod +x $CONFIG_STATUS
|
||||
rm -fr confdefs* $ac_clean_files
|
||||
test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
|
||||
|
||||
50
mozilla/directory/c-sdk/ldap/configure.in
Normal file
50
mozilla/directory/c-sdk/ldap/configure.in
Normal file
@@ -0,0 +1,50 @@
|
||||
dnl
|
||||
dnl The contents of this file are subject to the Mozilla Public
|
||||
dnl License Version 1.1 (the "License"); you may not use this file
|
||||
dnl except in compliance with the License. You may obtain a copy of
|
||||
dnl the License at http://www.mozilla.org/MPL/
|
||||
dnl
|
||||
dnl Software distributed under the License is distributed on an "AS
|
||||
dnl IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
dnl implied. See the License for the specific language governing
|
||||
dnl rights and limitations under the License.
|
||||
dnl
|
||||
dnl The Original Code is mozilla.org LDAP SDK autoconf glue.
|
||||
dnl
|
||||
dnl The Initial Developer of the Original Code is Netscape
|
||||
dnl Communications Corp. Portions created by Netscape are
|
||||
dnl Copyright (C) 2000, Netscape Communications Corp. All
|
||||
dnl Rights Reserved.
|
||||
dnl
|
||||
dnl Contributor(s): Dan Mosedale <dmose@mozilla.org>
|
||||
dnl
|
||||
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(build/dirver.c)
|
||||
dnl Checks for programs.
|
||||
dnl Checks for libraries.
|
||||
dnl Checks for header files.
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
dnl Checks for library functions.
|
||||
|
||||
dnl If the nsprpub whose configuration system we're using has been built with
|
||||
dnl --enable-nspr-autoconf, we need to cope with that here.
|
||||
dnl
|
||||
AC_ARG_ENABLE(nspr-autoconf,
|
||||
[ --enable-nspr-autoconf Enable building with an autoconf'ed NSPR tree],
|
||||
NSPR_USE_AUTOCONF=1, NSPR_USE_AUTOCONF=0)
|
||||
|
||||
AC_SUBST(NSPR_USE_AUTOCONF)
|
||||
|
||||
dnl Generate output files
|
||||
dnl
|
||||
MAKEFILES="
|
||||
Makefile
|
||||
build/Makefile
|
||||
build/autoconf.mk
|
||||
include/Makefile
|
||||
libraries/Makefile
|
||||
libraries/libldap/Makefile
|
||||
libraries/liblber/Makefile
|
||||
"
|
||||
AC_OUTPUT([$MAKEFILES])
|
||||
230
mozilla/directory/c-sdk/ldap/examples/Makefile
Normal file
230
mozilla/directory/c-sdk/ldap/examples/Makefile
Normal file
@@ -0,0 +1,230 @@
|
||||
#
|
||||
# Copyright (c) 1996-1998. Netscape Communications Corporation. All
|
||||
# rights reserved.
|
||||
#
|
||||
#
|
||||
# UNIX Makefile for Directory SDK examples
|
||||
#
|
||||
# SSL examples are not built by default. Use 'make ssl' to build them.
|
||||
# NSPR examples are not built by default. Use 'make nspr' to build them.
|
||||
#
|
||||
|
||||
###############################################################################
|
||||
# If you are not building on Solaris, you will need to comment out the
|
||||
# Solaris section and uncomment the appropriate section for your platform.
|
||||
#
|
||||
# Also note that the LDAP API library has different names for the SSL-enabled
|
||||
# and non-SSL versions of the Directory SDK for C:
|
||||
#
|
||||
# o In the SSL-enabled version, the library is named
|
||||
# libldapssl41.so on Solaris, IRIX, and AIX, and
|
||||
# libldapssl41.sl on HP-UX.
|
||||
#
|
||||
# o In the non-SSL version, the library is named
|
||||
# libldap41.so on Solaris, IRIX, and AIX, and
|
||||
# libldap41.sl on HP-UX.
|
||||
#
|
||||
# Remove the comment character in front of the definition of
|
||||
# LDAPLIB that matches the name of the LDAP API library for the
|
||||
# version you've downloaded.
|
||||
#
|
||||
|
||||
# For Solaris
|
||||
EXTRACFLAGS=
|
||||
EXTRALDFLAGS=-lsocket -lnsl
|
||||
EXTRANSPRLDFLAGS=-mt
|
||||
LDAPLIB=ldapssl41
|
||||
#LDAPLIB=ldap41
|
||||
LDAPPRLIB=ldappr41
|
||||
NSPRLIB=nspr3
|
||||
CC=cc
|
||||
|
||||
# For HP/UX (32 bit)
|
||||
#EXTRACFLAGS=-Dhpux -D_HPUX_SOURCE -D_REENTRANT -Aa
|
||||
#EXTRALDFLAGS=-Wl,+s+b
|
||||
#LDAPLIB=ldapssl41
|
||||
#LDAPLIB=ldap41
|
||||
#LDAPPRLIB=ldappr41
|
||||
#NSPRLIB=nspr3
|
||||
#CC=cc
|
||||
|
||||
# For HP/UX (64 bit)
|
||||
#EXTRACFLAGS=-DHPUX11 -DIS_64 +e +DA2.0W +DChpux +DS2.0
|
||||
#EXTRACFLAGS+=-D_LARGEFILE64_SOURCE -D_PR_HAVE_OFF64_T
|
||||
#EXTRALDFLAGS=-lpthread +DA2.0W +DS2.0
|
||||
#LDAPLIB=ldapssl41
|
||||
#LDAPLIB=ldap41
|
||||
#LDAPPRLIB=ldappr41
|
||||
#NSPRLIB=nspr3
|
||||
#CC=/opt/ansic/bin/cc
|
||||
|
||||
|
||||
# For IRIX
|
||||
#EXTRACFLAGS=
|
||||
#EXTRALDFLAGS=
|
||||
#LDAPLIB=ldapssl41
|
||||
#LDAPLIB=ldap41
|
||||
#LDAPPRLIB=ldappr41
|
||||
#NSPRLIB=nspr3
|
||||
#CC=cc
|
||||
|
||||
# For AIX
|
||||
#EXTRACFLAGS=
|
||||
#EXTRALDFLAGS=-brtl
|
||||
#LDAPLIB=ldapssl41
|
||||
#LDAPLIB=ldap41
|
||||
#LDAPPRLIB=ldappr41
|
||||
#NSPRLIB=nspr3
|
||||
#CC=cc
|
||||
|
||||
# For Digital UNIX 4.0
|
||||
#EXTRACFLAGS=
|
||||
#EXTRALDFLAGS=-taso -rpath ../lib
|
||||
#LDAPLIB=ldapssl41
|
||||
#LDAPLIB=ldap41
|
||||
#LDAPPRLIB=ldappr41
|
||||
#NSPRLIB=nspr3
|
||||
#CC=cc
|
||||
|
||||
# For Linux 2.2
|
||||
#EXTRACFLAGS=
|
||||
#EXTRALDFLAGS=-lpthread
|
||||
#LDAPLIB=ldapssl41
|
||||
#LDAPLIB=ldap41
|
||||
#LDAPPRLIB=ldappr41
|
||||
#NSPRLIB=nspr3
|
||||
#CC=gcc
|
||||
|
||||
###############################################################################
|
||||
# You should not need to change anything below here....
|
||||
|
||||
INCDIR=../include
|
||||
LIBDIR=../lib
|
||||
NSPRINCDIR=../include
|
||||
NSPRLIBDIR=../lib
|
||||
|
||||
LIBS=-L$(LIBDIR) -l$(LDAPLIB) $(EXTRALDFLAGS)
|
||||
NSPRLIBS=$(EXTRANSPRLDFLAGS) -L$(NSPRLIBDIR) -l$(NSPRLIB) -l$(LDAPPRLIB)
|
||||
OPTFLAGS=-g
|
||||
CFLAGS=$(OPTFLAGS) -I$(INCDIR) -I$(NSPRINCDIR) $(EXTRACFLAGS)
|
||||
NSPRCFLAGS=-I$(NSPRINCDIR)
|
||||
|
||||
PROGS=search asearch csearch psearch rdentry getattrs srvrsort modattrs add del compare modrdn ppolicy getfilt crtfilt
|
||||
|
||||
SSLPROGS=ssnoauth ssearch
|
||||
|
||||
NSPRPROGS=nsprio
|
||||
|
||||
ALLPROGS= $(PROGS)
|
||||
|
||||
standard: $(PROGS)
|
||||
|
||||
ssl: $(SSLPROGS)
|
||||
|
||||
nspr: $(NSPRPROGS)
|
||||
|
||||
all: $(ALLPROGS)
|
||||
|
||||
purify: $(PROGS)
|
||||
make clean; make CC="purify $(CC)"
|
||||
|
||||
search: search.o
|
||||
$(CC) -o search search.o $(LIBS)
|
||||
|
||||
search.o: examples.h
|
||||
|
||||
csearch: csearch.o
|
||||
$(CC) -o csearch csearch.o $(LIBS)
|
||||
|
||||
csearch.o: examples.h
|
||||
|
||||
psearch: psearch.o
|
||||
$(CC) -o psearch psearch.o $(LIBS)
|
||||
|
||||
psearch.o: examples.h
|
||||
|
||||
ssearch: ssearch.o
|
||||
$(CC) -o ssearch ssearch.o $(LIBS)
|
||||
|
||||
ssearch.o: examples.h
|
||||
|
||||
ssnoauth: ssnoauth.o
|
||||
$(CC) -o ssnoauth ssnoauth.o $(LIBS)
|
||||
|
||||
ssnoauth.o: examples.h
|
||||
|
||||
rdentry: rdentry.o
|
||||
$(CC) -o rdentry rdentry.o $(LIBS)
|
||||
|
||||
rdentry.o: examples.h
|
||||
|
||||
getattrs: getattrs.o
|
||||
$(CC) -o getattrs getattrs.o $(LIBS)
|
||||
|
||||
getattrs.o: examples.h
|
||||
|
||||
srvrsort: srvrsort.o
|
||||
$(CC) -o srvrsort srvrsort.o $(LIBS)
|
||||
|
||||
srvrsort.o: examples.h
|
||||
|
||||
modattrs: modattrs.o
|
||||
$(CC) -o modattrs modattrs.o $(LIBS)
|
||||
|
||||
modattrs.o: examples.h
|
||||
|
||||
asearch: asearch.o
|
||||
$(CC) -o asearch asearch.o $(LIBS)
|
||||
|
||||
asearch.o: examples.h
|
||||
|
||||
add: add.o
|
||||
$(CC) -o add add.o $(LIBS)
|
||||
|
||||
add.o: examples.h
|
||||
|
||||
del: del.o
|
||||
$(CC) -o del del.o $(LIBS)
|
||||
|
||||
del.o: examples.h
|
||||
|
||||
compare: compare.o
|
||||
$(CC) -o compare compare.o $(LIBS)
|
||||
|
||||
compare.o: examples.h
|
||||
|
||||
modrdn: modrdn.o
|
||||
$(CC) -o modrdn modrdn.o $(LIBS)
|
||||
|
||||
modrdn.o: examples.h
|
||||
|
||||
ppolicy: ppolicy.o
|
||||
$(CC) -o ppolicy ppolicy.o $(LIBS)
|
||||
|
||||
ppolicy.o: examples.h
|
||||
|
||||
getfilt: getfilt.o
|
||||
$(CC) -o getfilt getfilt.o $(LIBS)
|
||||
|
||||
getfilt.o: examples.h
|
||||
|
||||
crtfilt: crtfilt.o
|
||||
$(CC) -o crtfilt crtfilt.o $(LIBS)
|
||||
|
||||
crtfilt.o: examples.h
|
||||
|
||||
nsprio: nsprio.o
|
||||
$(CC) -o nsprio nsprio.o $(NSPRLIBS) $(LIBS)
|
||||
|
||||
nsprio.o: examples.h
|
||||
|
||||
runall: $(PROGS)
|
||||
@for i in $(PROGS); do \
|
||||
echo "-------------------------------------------------"; \
|
||||
echo "Executing $$i example..."; \
|
||||
./$$i; \
|
||||
echo "$$i example done."; \
|
||||
done
|
||||
|
||||
clean:
|
||||
/bin/rm -f $(ALLPROGS) *.o a.out core
|
||||
144
mozilla/directory/c-sdk/ldap/examples/README
Normal file
144
mozilla/directory/c-sdk/ldap/examples/README
Normal file
@@ -0,0 +1,144 @@
|
||||
Directory SDK Examples
|
||||
----------------------
|
||||
|
||||
This directory contains some sample LDAP code to help you understand
|
||||
how to use the Directory SDK. These examples are designed to work against
|
||||
the sample data contained in the Netscape Directory Server 4.x
|
||||
distribution. If you want to run these samples, you will need to have
|
||||
a working LDAP server running, and the sample "airius.com" data
|
||||
loaded.
|
||||
|
||||
NOTE: When linking to the LDAP API library, be aware that the different
|
||||
versions of the Directory SDK have libraries with different names:
|
||||
|
||||
- In the SSL-enabled version of the Netscape Directory SDK for C,
|
||||
the LDAP API library is named libldapssl41.so on Solaris, IRIX, and AIX,
|
||||
and libldapssl41.sl on HP-UX. The import library for Microsoft
|
||||
compilers is named nsldapssl32v41.lib, and the DLL is named
|
||||
nsldapssl32v41.dll.
|
||||
|
||||
- In the non-SSL version of the Netscape Directory SDK for C,
|
||||
the LDAP API library is named libldap41.so on Solaris, IRIX, and AIX,
|
||||
and libldap41.sl on HP-UX. The import library for Microsoft
|
||||
compilers is named nsldap32v41.lib, and the DLL is named
|
||||
nsldap32v41.dll.
|
||||
|
||||
|
||||
-------------------
|
||||
Synchronous samples
|
||||
-------------------
|
||||
These samples use the synchronous LDAP calls. These calls are more
|
||||
straightforward to use, and it's suggested you look at these examples
|
||||
first. These calls will block the calling process until all results
|
||||
have been returned, so they are probably not appropriate for use in a
|
||||
client with a graphical user interface which relies an an event loop.
|
||||
However, they're fine for command-line clients and CGI programs.
|
||||
|
||||
search.c
|
||||
--------
|
||||
Shows how to use ldap_search_s() to search for all entries which have
|
||||
an attribute value which exactly matches what you're searching for. In
|
||||
this example, all entries with the surname (last name) "Jensen" are
|
||||
retrieved and displayed.
|
||||
|
||||
csearch.c
|
||||
---------
|
||||
Like search.c, but enables an in-memory cache.
|
||||
|
||||
ssnoauth.c
|
||||
----------
|
||||
Like search.c, but the search is done over SSL.
|
||||
|
||||
ssearch.c
|
||||
---------
|
||||
Like ssnoauth.c, but with certificate based authentication thrown in.
|
||||
|
||||
srvrsort.c
|
||||
----------
|
||||
Shows how to use server side sorting in conjunction with the
|
||||
ldap_search_ext_s() function.
|
||||
|
||||
rdentry.c
|
||||
---------
|
||||
Shows how to use ldap_search_s() to retrieve a particular entry from the
|
||||
directory. In this example, the entry "uid=bjensen, ou=People, o=airius.com"
|
||||
is retrieved and displayed.
|
||||
|
||||
getattrs.c
|
||||
----------
|
||||
Just like read.c, but retrieves specific attributes from an entry.
|
||||
|
||||
compare.c
|
||||
---------
|
||||
Show how to use ldap_compare_s(), which allows you to test if a particular
|
||||
value is contained in an attribute of an entry.
|
||||
|
||||
modattrs.c
|
||||
----------
|
||||
Shows how to use ldap_modify_s() to replace and add to values in an attribute.
|
||||
|
||||
modrdn.c
|
||||
--------
|
||||
Shows how to use ldap_modrdn2_s() to change the relative distinguished name
|
||||
(rdn) of an entry.
|
||||
|
||||
getfilt.c
|
||||
---------
|
||||
Shows how to use the ldap_getfilter family of routines, which help generate
|
||||
LDAP filters based on an arbitrary search string provided by a user.
|
||||
|
||||
crtfilt.c
|
||||
---------
|
||||
Shows how to use the ldap_create_filter() function to generate LDAP filters.
|
||||
|
||||
|
||||
|
||||
---------------------
|
||||
Asynchronous examples
|
||||
---------------------
|
||||
These examples use the asynchronous LDAP calls. The general idea is that
|
||||
you begin an operation, and then periodically poll to see if any results
|
||||
have been returned.
|
||||
|
||||
asearch.c
|
||||
---------
|
||||
Initiates a search for entries, and polls for results, printing them as
|
||||
they arrive.
|
||||
|
||||
nsprio.c
|
||||
--------
|
||||
Like asearch.c but using the prldap routines to incorporate NSPR.
|
||||
|
||||
add.c
|
||||
------
|
||||
Add an entry to the directory.
|
||||
|
||||
del.c
|
||||
------
|
||||
Delete an entry from the directory.
|
||||
|
||||
psearch.c
|
||||
---------
|
||||
Shows how to use the Persistent Search LDAPv3 protocol extension to
|
||||
monitor a directory server for changes.
|
||||
|
||||
ppolicy.c
|
||||
---------
|
||||
Attempt to bind to the directory, and report back any password expiration
|
||||
information received. This demonstrates how clients can process password
|
||||
policy information that is optionally returned by Netscape Directory Server
|
||||
3.0 and later.
|
||||
|
||||
|
||||
|
||||
-------------------
|
||||
Additional examples
|
||||
-------------------
|
||||
The Macintosh or Windows versions of the Directory SDK also include
|
||||
sample project files. A sample CodeWarrior project file is included
|
||||
in the macintosh directory.
|
||||
|
||||
Sample Visual C++ makefiles for a Windows application (winldap) are
|
||||
included in the windows directory. The Win32 version of the makefile
|
||||
is named winldap.mak; the Win16 version of the makefile is named LDAP16.MAK.
|
||||
|
||||
156
mozilla/directory/c-sdk/ldap/examples/add.c
Normal file
156
mozilla/directory/c-sdk/ldap/examples/add.c
Normal file
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright (c) 1996. Netscape Communications Corporation. All
|
||||
* rights reserved.
|
||||
*
|
||||
* Add a new entry to the directory.
|
||||
*
|
||||
* Instead of calling the synchronous ldap_add_s() routine, we call
|
||||
* the asynchronous routine ldap_add() and poll for results using
|
||||
* ldap_result().
|
||||
*
|
||||
* Since it is an error to attempt to add an entry which already exists,
|
||||
* you cannot run this example program twice in a row. You can use the
|
||||
* adel.c example program to delete the entry which this example adds.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "examples.h"
|
||||
|
||||
static void do_other_work();
|
||||
unsigned long global_counter = 0;
|
||||
static void free_mods( LDAPMod **mods );
|
||||
|
||||
#define NMODS 5
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
LDAP *ld;
|
||||
LDAPMessage *result;
|
||||
char *dn;
|
||||
int i;
|
||||
int rc;
|
||||
int msgid;
|
||||
int finished;
|
||||
struct timeval zerotime;
|
||||
LDAPMod **mods;
|
||||
|
||||
char *objectclass_values[] = { "top", "person", "organizationalPerson",
|
||||
"inetOrgPerson", NULL };
|
||||
char *cn_values[] = { "William B Jensen", "William Jensen", "Bill Jensen",
|
||||
NULL };
|
||||
char *sn_values[] = { "Jensen", NULL };
|
||||
char *givenname_values[] = { "William", "Bill", NULL };
|
||||
char *telephonenumber_values[] = { "+1 415 555 1212", NULL };
|
||||
|
||||
zerotime.tv_sec = zerotime.tv_usec = 0L;
|
||||
|
||||
/* Specify the DN we're adding */
|
||||
dn = "cn=William B Jensen, " PEOPLE_BASE; /* see examples.h */
|
||||
|
||||
/* get a handle to an LDAP connection */
|
||||
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
|
||||
perror( "ldap_init" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* authenticate to the directory as the Directory Manager */
|
||||
if ( ldap_simple_bind_s( ld, MGR_DN, MGR_PW ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_simple_bind_s" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* Construct the array of values to add */
|
||||
mods = ( LDAPMod ** ) malloc(( NMODS + 1 ) * sizeof( LDAPMod * ));
|
||||
if ( mods == NULL ) {
|
||||
fprintf( stderr, "Cannot allocate memory for mods array\n" );
|
||||
}
|
||||
for ( i = 0; i < NMODS; i++ ) {
|
||||
if (( mods[ i ] = ( LDAPMod * ) malloc( sizeof( LDAPMod ))) == NULL ) {
|
||||
fprintf( stderr, "Cannot allocate memory for mods element\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
mods[ 0 ]->mod_op = 0;
|
||||
mods[ 0 ]->mod_type = "objectclass";
|
||||
mods[ 0 ]->mod_values = objectclass_values;
|
||||
mods[ 1 ]->mod_op = 0;
|
||||
mods[ 1 ]->mod_type = "cn";
|
||||
mods[ 1 ]->mod_values = cn_values;
|
||||
mods[ 2 ]->mod_op = 0;
|
||||
mods[ 2 ]->mod_type = "sn";
|
||||
mods[ 2 ]->mod_values = sn_values;
|
||||
mods[ 3 ]->mod_op = 0;
|
||||
mods[ 3 ]->mod_type = "givenname";
|
||||
mods[ 3 ]->mod_values = givenname_values;
|
||||
mods[ 4 ]->mod_op = 0;
|
||||
mods[ 4 ]->mod_type = "telephonenumber";
|
||||
mods[ 4 ]->mod_values = telephonenumber_values;
|
||||
mods[ 5 ] = NULL;
|
||||
|
||||
|
||||
/* Initiate the add operation */
|
||||
if (( msgid = ldap_add( ld, dn, mods )) < 0 ) {
|
||||
ldap_perror( ld, "ldap_add" );
|
||||
free_mods( mods );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* Poll for the result */
|
||||
finished = 0;
|
||||
while ( !finished ) {
|
||||
rc = ldap_result( ld, msgid, LDAP_MSG_ONE, &zerotime, &result );
|
||||
switch ( rc ) {
|
||||
case -1:
|
||||
/* some error occurred */
|
||||
ldap_perror( ld, "ldap_result" );
|
||||
free_mods( mods );
|
||||
return( 1 );
|
||||
case 0:
|
||||
/* Timeout was exceeded. No entries are ready for retrieval */
|
||||
break;
|
||||
default:
|
||||
/* Should be finished here */
|
||||
finished = 1;
|
||||
if (( rc = ldap_result2error( ld, result, 0 )) == LDAP_SUCCESS ) {
|
||||
printf( "Entry added successfully. I counted to %ld "
|
||||
"while waiting.\n", global_counter );
|
||||
} else {
|
||||
printf( "Error while adding entry: %s\n",
|
||||
ldap_err2string( rc ));
|
||||
}
|
||||
ldap_msgfree( result );
|
||||
}
|
||||
do_other_work();
|
||||
}
|
||||
ldap_unbind( ld );
|
||||
free_mods( mods );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Free a mods array.
|
||||
*/
|
||||
static void
|
||||
free_mods( LDAPMod **mods )
|
||||
{
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < NMODS; i++ ) {
|
||||
free( mods[ i ] );
|
||||
}
|
||||
free( mods );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Perform other work while polling for results. This doesn't do anything
|
||||
* useful, but it could.
|
||||
*/
|
||||
static void
|
||||
do_other_work()
|
||||
{
|
||||
global_counter++;
|
||||
}
|
||||
132
mozilla/directory/c-sdk/ldap/examples/asearch.c
Normal file
132
mozilla/directory/c-sdk/ldap/examples/asearch.c
Normal file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (c) 1996. Netscape Communications Corporation. All
|
||||
* rights reserved.
|
||||
*
|
||||
* Search the directory for all people whose surname (last name) is
|
||||
* "Jensen". Since the "sn" attribute is a caseignorestring (cis), case
|
||||
* is not significant when searching.
|
||||
*
|
||||
* Instead of calling the synchronous ldap_search_s() routine, we call
|
||||
* the asynchronous routine ldap_search() and poll for results using
|
||||
* ldap_result().
|
||||
*
|
||||
*/
|
||||
|
||||
#include "examples.h"
|
||||
|
||||
static void do_other_work();
|
||||
unsigned long global_counter = 0;
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
LDAP *ld;
|
||||
LDAPMessage *result, *e;
|
||||
BerElement *ber;
|
||||
char *a, *dn;
|
||||
char **vals;
|
||||
int i;
|
||||
int rc;
|
||||
int finished;
|
||||
int msgid;
|
||||
int num_entries = 0;
|
||||
struct timeval zerotime;
|
||||
|
||||
zerotime.tv_sec = zerotime.tv_usec = 0L;
|
||||
|
||||
/* get a handle to an LDAP connection */
|
||||
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
|
||||
perror( "ldap_init" );
|
||||
return( 1 );
|
||||
}
|
||||
/* authenticate to the directory as nobody */
|
||||
if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_simple_bind_s" );
|
||||
return( 1 );
|
||||
}
|
||||
/* search for all entries with surname of Jensen */
|
||||
if (( msgid = ldap_search( ld, MY_SEARCHBASE, LDAP_SCOPE_SUBTREE,
|
||||
MY_FILTER, NULL, 0 )) < 0 ) {
|
||||
ldap_perror( ld, "ldap_search" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* Loop, polling for results until finished */
|
||||
finished = 0;
|
||||
while ( !finished ) {
|
||||
/*
|
||||
* Poll for results. We call ldap_result with the "all" argument
|
||||
* set to LDAP_MSG_ONE. This causes ldap_result() to return exactly one
|
||||
* entry if at least one entry is available. This allows us to
|
||||
* display the entries as they are received.
|
||||
*/
|
||||
result = NULL;
|
||||
rc = ldap_result( ld, msgid, LDAP_MSG_ONE, &zerotime, &result );
|
||||
switch ( rc ) {
|
||||
case -1:
|
||||
/* some error occurred */
|
||||
ldap_perror( ld, "ldap_result" );
|
||||
return( 1 );
|
||||
case 0:
|
||||
/* Timeout was exceeded. No entries are ready for retrieval. */
|
||||
if ( result != NULL ) {
|
||||
ldap_msgfree( result );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/*
|
||||
* Either an entry is ready for retrieval, or all entries have
|
||||
* been retrieved.
|
||||
*/
|
||||
if (( e = ldap_first_entry( ld, result )) == NULL ) {
|
||||
/* All done */
|
||||
finished = 1;
|
||||
if ( result != NULL ) {
|
||||
ldap_msgfree( result );
|
||||
}
|
||||
continue;
|
||||
}
|
||||
/* for each entry print out name + all attrs and values */
|
||||
num_entries++;
|
||||
if (( dn = ldap_get_dn( ld, e )) != NULL ) {
|
||||
printf( "dn: %s\n", dn );
|
||||
ldap_memfree( dn );
|
||||
}
|
||||
for ( a = ldap_first_attribute( ld, e, &ber );
|
||||
a != NULL; a = ldap_next_attribute( ld, e, ber ) ) {
|
||||
if (( vals = ldap_get_values( ld, e, a )) != NULL ) {
|
||||
for ( i = 0; vals[ i ] != NULL; i++ ) {
|
||||
printf( "%s: %s\n", a, vals[ i ] );
|
||||
}
|
||||
ldap_value_free( vals );
|
||||
}
|
||||
ldap_memfree( a );
|
||||
}
|
||||
if ( ber != NULL ) {
|
||||
ber_free( ber, 0 );
|
||||
}
|
||||
printf( "\n" );
|
||||
ldap_msgfree( result );
|
||||
}
|
||||
/* Do other work here while you are waiting... */
|
||||
do_other_work();
|
||||
}
|
||||
|
||||
/* All done. Print a summary. */
|
||||
printf( "%d entries retrieved. I counted to %ld "
|
||||
"while I was waiting.\n", num_entries,
|
||||
global_counter );
|
||||
ldap_unbind( ld );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Perform other work while polling for results. This doesn't do anything
|
||||
* useful, but it could.
|
||||
*/
|
||||
static void
|
||||
do_other_work()
|
||||
{
|
||||
global_counter++;
|
||||
}
|
||||
65
mozilla/directory/c-sdk/ldap/examples/compare.c
Normal file
65
mozilla/directory/c-sdk/ldap/examples/compare.c
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 1996. Netscape Communications Corporation. All
|
||||
* rights reserved.
|
||||
*
|
||||
* Use ldap_compare() to compare values agains values contained in entry
|
||||
* ENTRYDN (defined in examples.h)
|
||||
* We test to see if (1) the value "person" is one of the values in the
|
||||
* objectclass attribute (it is), and if (2) the value "xyzzy" is in the
|
||||
* objectlass attribute (it isn't, or at least, it shouldn't be).
|
||||
*
|
||||
*/
|
||||
|
||||
#include "examples.h"
|
||||
|
||||
int
|
||||
main( int main, char **argv )
|
||||
{
|
||||
LDAP *ld;
|
||||
int rc;
|
||||
|
||||
/* get a handle to an LDAP connection */
|
||||
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
|
||||
perror( "ldap_init" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* authenticate to the directory as nobody */
|
||||
if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_simple_bind_s" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* compare the value "person" against the objectclass attribute */
|
||||
rc = ldap_compare_s( ld, ENTRYDN, "objectclass", "person" );
|
||||
switch ( rc ) {
|
||||
case LDAP_COMPARE_TRUE:
|
||||
printf( "The value \"person\" is contained in the objectclass "
|
||||
"attribute.\n" );
|
||||
break;
|
||||
case LDAP_COMPARE_FALSE:
|
||||
printf( "The value \"person\" is not contained in the objectclass "
|
||||
"attribute.\n" );
|
||||
break;
|
||||
default:
|
||||
ldap_perror( ld, "ldap_compare_s" );
|
||||
}
|
||||
|
||||
/* compare the value "xyzzy" against the objectclass attribute */
|
||||
rc = ldap_compare_s( ld, ENTRYDN, "objectclass", "xyzzy" );
|
||||
switch ( rc ) {
|
||||
case LDAP_COMPARE_TRUE:
|
||||
printf( "The value \"xyzzy\" is contained in the objectclass "
|
||||
"attribute.\n" );
|
||||
break;
|
||||
case LDAP_COMPARE_FALSE:
|
||||
printf( "The value \"xyzzy\" is not contained in the objectclass "
|
||||
"attribute.\n" );
|
||||
break;
|
||||
default:
|
||||
ldap_perror( ld, "ldap_compare_s" );
|
||||
}
|
||||
|
||||
ldap_unbind( ld );
|
||||
return( 0 );
|
||||
}
|
||||
151
mozilla/directory/c-sdk/ldap/examples/crtfilt.c
Normal file
151
mozilla/directory/c-sdk/ldap/examples/crtfilt.c
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright (c) 1999. Netscape Communications Corporation. All
|
||||
* rights reserved.
|
||||
*
|
||||
* Demonstrate use of the create filter function.
|
||||
*/
|
||||
|
||||
#include "examples.h"
|
||||
|
||||
#define FILT_BUFSIZ 4096
|
||||
|
||||
struct filt_words {
|
||||
char **f_words;
|
||||
char *f_internal;
|
||||
};
|
||||
|
||||
static int get_string_input( const char *prompt, const char *defaultval,
|
||||
char *resultbuf );
|
||||
static struct filt_words *val2words( const char *value, const char *delims );
|
||||
static void freewords( struct filt_words *words );
|
||||
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
int rc;
|
||||
char patbuf[ FILT_BUFSIZ ];
|
||||
char attrbuf[ FILT_BUFSIZ ], valuebuf[ FILT_BUFSIZ ];
|
||||
char filtbuf[ FILT_BUFSIZ ];
|
||||
struct filt_words *fwords;
|
||||
|
||||
patbuf[0] = attrbuf[0] = valuebuf[0] = '\0';
|
||||
|
||||
while ( 1 ) {
|
||||
if ( get_string_input( "Enter a filter pattern: [%s] ", patbuf,
|
||||
patbuf ) != 0 ) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( get_string_input( "Enter an attribute type: [%s] ", attrbuf,
|
||||
attrbuf ) != 0 ) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( get_string_input( "Enter a value: [%s] ", valuebuf,
|
||||
valuebuf ) != 0 ) {
|
||||
break;
|
||||
}
|
||||
|
||||
fwords = val2words( valuebuf, " " );
|
||||
rc = ldap_create_filter( filtbuf, sizeof( filtbuf ), patbuf,
|
||||
NULL, NULL, attrbuf, valuebuf, fwords->f_words );
|
||||
freewords( fwords );
|
||||
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
fprintf( stderr, "ldap_create_filter: failed (%d - %s)\n", rc,
|
||||
ldap_err2string( rc ));
|
||||
} else {
|
||||
printf( "Resulting filter: %s\n", filtbuf );
|
||||
}
|
||||
putchar( '\n' );
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Prompt the user for a string. The entered string is placed in resultbuf.
|
||||
* If a zero-length string is entered, i.e., if they just hit return, the
|
||||
* contents of defaultval are copied to resultbuf.
|
||||
* Returns 0 if all goes well and -1 if error or end of file.
|
||||
*/
|
||||
static int
|
||||
get_string_input( const char *prompt, const char *defaultval, char *resultbuf )
|
||||
{
|
||||
char inbuf[ FILT_BUFSIZ ];
|
||||
|
||||
inbuf[0] = '\0';
|
||||
printf( prompt, defaultval );
|
||||
if ( fgets( inbuf, sizeof( inbuf ), stdin ) == NULL ) {
|
||||
return( -1 );
|
||||
}
|
||||
inbuf[ strlen( inbuf ) - 1 ] = '\0'; /* strip trailing newline */
|
||||
if ( inbuf[ 0 ] == '\0' ) { /* use default value */
|
||||
if ( defaultval != resultbuf ) {
|
||||
strcpy( resultbuf, defaultval );
|
||||
}
|
||||
} else { /* use newly entered value */
|
||||
strcpy( resultbuf, inbuf );
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
static struct filt_words *
|
||||
val2words( const char *value, const char *delims )
|
||||
{
|
||||
struct filt_words *fw;
|
||||
char *word;
|
||||
int i;
|
||||
|
||||
if (( fw = calloc( 1, sizeof( struct filt_words ))) == NULL ||
|
||||
( fw->f_internal = strdup( value )) == NULL ) {
|
||||
perror( "calloc OR strdup" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
word = strtok( fw->f_internal, delims );
|
||||
i = 0;
|
||||
|
||||
while ( word != NULL ) {
|
||||
if ( fw->f_words == NULL ) {
|
||||
fw->f_words = (char **)malloc( (i + 2 ) * sizeof( char * ));
|
||||
} else {
|
||||
fw->f_words = (char **)realloc( fw->f_words,
|
||||
(i + 2 ) * sizeof( char * ));
|
||||
}
|
||||
|
||||
if ( fw->f_words == NULL ) {
|
||||
perror( "malloc OR realloc" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
fw->f_words[ i ] = word;
|
||||
fw->f_words[ ++i ] = NULL;
|
||||
word = strtok( NULL, delims );
|
||||
}
|
||||
|
||||
if ( i > 0 ) {
|
||||
fw->f_words[ i ] = NULL;
|
||||
}
|
||||
|
||||
return( fw );
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
freewords( struct filt_words *words )
|
||||
{
|
||||
if ( words != NULL ) {
|
||||
if ( words->f_words != NULL ) {
|
||||
free( words->f_words );
|
||||
}
|
||||
if ( words->f_internal != NULL ) {
|
||||
free( words->f_internal );
|
||||
}
|
||||
free( words );
|
||||
}
|
||||
}
|
||||
117
mozilla/directory/c-sdk/ldap/examples/csearch.c
Normal file
117
mozilla/directory/c-sdk/ldap/examples/csearch.c
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2000. Netscape Communications Corporation. All
|
||||
* rights reserved.
|
||||
*
|
||||
* Enable the in-memory cache and then search the directory 10 times
|
||||
* for all people whose surname (last name) is "Jensen". Since the
|
||||
* "sn" attribute is a caseignorestring (cis), case is not significant
|
||||
* when searching.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "examples.h"
|
||||
|
||||
LDAP *ld;
|
||||
LDAPMessage *result, *e;
|
||||
BerElement *ber;
|
||||
char *a, *dn;
|
||||
char **vals;
|
||||
int i, j;
|
||||
LDAPMemCache *cacheHandle;
|
||||
int memCache;
|
||||
|
||||
int mySearch();
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
/* get a handle to an LDAP connection */
|
||||
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
|
||||
perror( "ldap_init" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
memCache=ldap_memcache_init( 1800, 1024L * 1024, NULL, NULL, &cacheHandle );
|
||||
|
||||
switch ( memCache )
|
||||
{
|
||||
case LDAP_SUCCESS :
|
||||
printf("LDAP_SUCCESS\n");
|
||||
printf("LDAP_SUCCESS = %d\n", LDAP_SUCCESS);
|
||||
printf("memCache = %d\n", memCache);
|
||||
break;
|
||||
case LDAP_PARAM_ERROR:
|
||||
printf("LDAP_PARAM_ERROR\n");
|
||||
break;
|
||||
case LDAP_NO_MEMORY:
|
||||
printf("LDAP_NO_MEMORY\n");
|
||||
break;
|
||||
case LDAP_SIZELIMIT_EXCEEDED:
|
||||
printf("LDAP_SIZELIMITE_EXCEEDED\n");
|
||||
break;
|
||||
default :
|
||||
printf("Unknown Error = %d\n", memCache);
|
||||
break;
|
||||
};
|
||||
|
||||
/* authenticate to the directory as nobody */
|
||||
if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_simple_bind_s" );
|
||||
ldap_unbind( ld );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
ldap_memcache_set( ld, cacheHandle );
|
||||
|
||||
|
||||
for ( j = 0; j < 10; ++j ) {
|
||||
#ifdef _WINDOWS
|
||||
Sleep( 1000 );
|
||||
#else
|
||||
sleep( 1 );
|
||||
#endif
|
||||
mySearch();
|
||||
}
|
||||
|
||||
ldap_memcache_destroy( cacheHandle );
|
||||
ldap_unbind( ld );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mySearch()
|
||||
{
|
||||
/* search for all entries with surname of Jensen */
|
||||
if ( ldap_search_s( ld, MY_SEARCHBASE, LDAP_SCOPE_SUBTREE,
|
||||
MY_FILTER, NULL, 0, &result ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_search_s" );
|
||||
if ( result == NULL ) {
|
||||
ldap_unbind( ld );
|
||||
return( 1 );
|
||||
}
|
||||
}
|
||||
/* for each entry print out name + all attrs and values */
|
||||
for ( e = ldap_first_entry( ld, result ); e != NULL;
|
||||
e = ldap_next_entry( ld, e ) ) {
|
||||
if ( (dn = ldap_get_dn( ld, e )) != NULL ) {
|
||||
printf( "dn: %s\n", dn );
|
||||
ldap_memfree( dn );
|
||||
}
|
||||
for ( a = ldap_first_attribute( ld, e, &ber );
|
||||
a != NULL; a = ldap_next_attribute( ld, e, ber ) ) {
|
||||
if ((vals = ldap_get_values( ld, e, a)) != NULL ) {
|
||||
for ( i = 0; vals[i] != NULL; i++ ) {
|
||||
printf( "%s: %s\n", a, vals[i] );
|
||||
}
|
||||
ldap_value_free( vals );
|
||||
}
|
||||
ldap_memfree( a );
|
||||
}
|
||||
if ( ber != NULL ) {
|
||||
ber_free( ber, 0 );
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
ldap_msgfree( result );
|
||||
return( 0 );
|
||||
}
|
||||
93
mozilla/directory/c-sdk/ldap/examples/del.c
Normal file
93
mozilla/directory/c-sdk/ldap/examples/del.c
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 1996. Netscape Communications Corporation. All
|
||||
* rights reserved.
|
||||
*
|
||||
* Delete an entry from the directory.
|
||||
*
|
||||
* Instead of calling the synchronous ldap_delete_s() routine, we call
|
||||
* the asynchronous routine ldap_delete() and poll for results using
|
||||
* ldap_result().
|
||||
*
|
||||
* Since it is an error to attempt to delete an entry which does not
|
||||
* exist, you cannot run this example until you have added the entry
|
||||
* with the aadd.c example program.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "examples.h"
|
||||
|
||||
static void do_other_work();
|
||||
unsigned long global_counter = 0;
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
LDAP *ld;
|
||||
LDAPMessage *result;
|
||||
char *dn;
|
||||
int rc;
|
||||
int msgid;
|
||||
int finished;
|
||||
struct timeval zerotime;
|
||||
|
||||
zerotime.tv_sec = zerotime.tv_usec = 0L;
|
||||
|
||||
/* Specify the DN we're deleting */
|
||||
dn = "cn=William B Jensen, " PEOPLE_BASE; /* see examples.h */
|
||||
|
||||
/* get a handle to an LDAP connection */
|
||||
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
|
||||
perror( "ldap_init" );
|
||||
return( 1 );
|
||||
}
|
||||
/* authenticate to the directory as the Directory Manager */
|
||||
if ( ldap_simple_bind_s( ld, MGR_DN, MGR_PW ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_simple_bind_s" );
|
||||
return( 1 );
|
||||
}
|
||||
/* Initiate the delete operation */
|
||||
if (( msgid = ldap_delete( ld, dn )) < 0 ) {
|
||||
ldap_perror( ld, "ldap_delete" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* Poll for the result */
|
||||
finished = 0;
|
||||
while ( !finished ) {
|
||||
rc = ldap_result( ld, msgid, LDAP_MSG_ONE, &zerotime, &result );
|
||||
switch ( rc ) {
|
||||
case -1:
|
||||
/* some error occurred */
|
||||
ldap_perror( ld, "ldap_result" );
|
||||
return( 1 );
|
||||
case 0:
|
||||
/* Timeout was exceeded. No entries are ready for retrieval */
|
||||
break;
|
||||
default:
|
||||
/* Should be finished here */
|
||||
finished = 1;
|
||||
if (( rc = ldap_result2error( ld, result, 0 )) == LDAP_SUCCESS ) {
|
||||
printf( "Entry deleted successfully. I counted to %ld "
|
||||
"while waiting.\n", global_counter );
|
||||
} else {
|
||||
printf( "Error while deleting entry: %s\n",
|
||||
ldap_err2string( rc ));
|
||||
}
|
||||
ldap_msgfree( result );
|
||||
}
|
||||
do_other_work();
|
||||
}
|
||||
ldap_unbind( ld );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Perform other work while polling for results. This doesn't do anything
|
||||
* useful, but it could.
|
||||
*/
|
||||
static void
|
||||
do_other_work()
|
||||
{
|
||||
global_counter++;
|
||||
}
|
||||
88
mozilla/directory/c-sdk/ldap/examples/examples.h
Normal file
88
mozilla/directory/c-sdk/ldap/examples/examples.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) 1996. Netscape Communications Corporation. All
|
||||
* rights reserved.
|
||||
*
|
||||
* Common definitions for ldap example programs.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <ldap.h>
|
||||
|
||||
/*
|
||||
* Host name of LDAP server
|
||||
*/
|
||||
#define MY_HOST "localhost"
|
||||
|
||||
/*
|
||||
* Port number where LDAP server is running
|
||||
*/
|
||||
#define MY_PORT LDAP_PORT
|
||||
|
||||
/*
|
||||
* Port number where LDAPS server is running
|
||||
*/
|
||||
#define MY_SSL_PORT LDAPS_PORT
|
||||
|
||||
/*
|
||||
* DN of directory manager entry. This entry should have write access to
|
||||
* the entire directory.
|
||||
*/
|
||||
#define MGR_DN "cn=Directory Manager"
|
||||
|
||||
/*
|
||||
* Password for manager DN.
|
||||
*/
|
||||
#define MGR_PW "secret99"
|
||||
|
||||
/*
|
||||
* Subtree to search
|
||||
*/
|
||||
#define MY_SEARCHBASE "o=Airius.com"
|
||||
|
||||
/*
|
||||
* Place where people entries are stored
|
||||
*/
|
||||
#define PEOPLE_BASE "ou=People, " MY_SEARCHBASE
|
||||
|
||||
/*
|
||||
* DN of a user entry. This entry does not need any special access to the
|
||||
* directory (it is not used to perform modifies, for example).
|
||||
*/
|
||||
#define USER_DN "uid=scarter, " PEOPLE_BASE
|
||||
|
||||
/*
|
||||
* Password of the user entry.
|
||||
*/
|
||||
#define USER_PW "sprain"
|
||||
|
||||
/*
|
||||
* Filter to use when searching. This one searches for all entries with the
|
||||
* surname (last name) of "Jensen".
|
||||
*/
|
||||
#define MY_FILTER "(sn=Jensen)"
|
||||
|
||||
/*
|
||||
* Entry to retrieve
|
||||
*/
|
||||
#define ENTRYDN "uid=bjensen, " PEOPLE_BASE
|
||||
|
||||
/*
|
||||
* Password for Babs' entry
|
||||
*/
|
||||
#define ENTRYPW "hifalutin"
|
||||
|
||||
/*
|
||||
* Name of file containing filters
|
||||
*/
|
||||
#define MY_FILTERFILE "xmplflt.conf"
|
||||
|
||||
/*
|
||||
* Tag to use when retrieveing filters
|
||||
*/
|
||||
#define MY_FILTERTAG "ldap-example"
|
||||
|
||||
71
mozilla/directory/c-sdk/ldap/examples/getattrs.c
Normal file
71
mozilla/directory/c-sdk/ldap/examples/getattrs.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 1996. Netscape Communications Corporation. All
|
||||
* rights reserved.
|
||||
*
|
||||
* Retrieve several attributes of a particular entry.
|
||||
*/
|
||||
|
||||
#include "examples.h"
|
||||
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
LDAP *ld;
|
||||
LDAPMessage *result, *e;
|
||||
char **vals, *attrs[ 5 ];
|
||||
int i;
|
||||
|
||||
/* get a handle to an LDAP connection */
|
||||
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
|
||||
perror( "ldap_init" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
attrs[ 0 ] = "cn"; /* Get canonical name(s) (full name) */
|
||||
attrs[ 1 ] = "sn"; /* Get surname(s) (last name) */
|
||||
attrs[ 2 ] = "mail"; /* Get email address(es) */
|
||||
attrs[ 3 ] = "telephonenumber"; /* Get telephone number(s) */
|
||||
attrs[ 4 ] = NULL;
|
||||
|
||||
if ( ldap_search_s( ld, ENTRYDN, LDAP_SCOPE_BASE,
|
||||
"(objectclass=*)", attrs, 0, &result ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_search_s" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* print it out */
|
||||
if (( e = ldap_first_entry( ld, result )) != NULL ) {
|
||||
if (( vals = ldap_get_values( ld, e, "cn" )) != NULL ) {
|
||||
printf( "Full name:\n" );
|
||||
for ( i = 0; vals[i] != NULL; i++ ) {
|
||||
printf( "\t%s\n", vals[i] );
|
||||
}
|
||||
ldap_value_free( vals );
|
||||
}
|
||||
if (( vals = ldap_get_values( ld, e, "sn" )) != NULL ) {
|
||||
printf( "Last name (surname):\n" );
|
||||
for ( i = 0; vals[i] != NULL; i++ ) {
|
||||
printf( "\t%s\n", vals[i] );
|
||||
}
|
||||
ldap_value_free( vals );
|
||||
}
|
||||
if (( vals = ldap_get_values( ld, e, "mail" )) != NULL ) {
|
||||
printf( "Email address:\n" );
|
||||
for ( i = 0; vals[i] != NULL; i++ ) {
|
||||
printf( "\t%s\n", vals[i] );
|
||||
}
|
||||
ldap_value_free( vals );
|
||||
}
|
||||
if (( vals = ldap_get_values( ld, e, "telephonenumber" )) != NULL ) {
|
||||
printf( "Telephone number:\n" );
|
||||
for ( i = 0; vals[i] != NULL; i++ ) {
|
||||
printf( "\t%s\n", vals[i] );
|
||||
}
|
||||
ldap_value_free( vals );
|
||||
}
|
||||
}
|
||||
ldap_msgfree( result );
|
||||
ldap_unbind( ld );
|
||||
return( 0 );
|
||||
}
|
||||
105
mozilla/directory/c-sdk/ldap/examples/getfilt.c
Normal file
105
mozilla/directory/c-sdk/ldap/examples/getfilt.c
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (c) 1996. Netscape Communications Corporation. All
|
||||
* rights reserved.
|
||||
*
|
||||
* Search for a user-provided string, using a filter configuration file.
|
||||
* The filter config file controls which type of search is done, based
|
||||
* on what the user types.
|
||||
*/
|
||||
|
||||
#include "examples.h"
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
LDAP *ld;
|
||||
LDAPMessage *result, *e;
|
||||
BerElement *ber;
|
||||
char *a, *dn;
|
||||
char **vals;
|
||||
int i;
|
||||
LDAPFiltDesc *ldfp;
|
||||
LDAPFiltInfo *ldfi;
|
||||
char buf[ 80 ];
|
||||
int found;
|
||||
|
||||
/* Open the filter config file */
|
||||
if (( ldfp = ldap_init_getfilter( MY_FILTERFILE )) == NULL ) {
|
||||
fprintf( stderr, "Can't open filter file \"%s\"\n", MY_FILTERFILE );
|
||||
return( 1 );
|
||||
}
|
||||
/* Read a string to search for */
|
||||
printf( "Enter a string to search for: " );
|
||||
gets( buf );
|
||||
if ( strlen( buf ) == 0 ) {
|
||||
fprintf( stderr, "usage: %s search-string\n", argv[ 0 ]);
|
||||
return( 1 );
|
||||
}
|
||||
/* get a handle to an LDAP connection */
|
||||
printf( "Initializing LDAP library... " ); fflush( stdout );
|
||||
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
|
||||
perror( "ldap_init" );
|
||||
return( 1 );
|
||||
}
|
||||
printf( "done.\n" ); fflush( stdout );
|
||||
/* authenticate to the directory as nobody */
|
||||
printf( "Binding to the directory... " ); fflush( stdout );
|
||||
if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_simple_bind_s" );
|
||||
return( 1 );
|
||||
}
|
||||
printf( "done.\n" ); fflush( stdout );
|
||||
/* search for what the user typed */
|
||||
found = 0;
|
||||
for ( ldfi = ldap_getfirstfilter( ldfp, MY_FILTERTAG, buf );
|
||||
ldfi != NULL; ldfi = ldap_getnextfilter( ldfp )) {
|
||||
printf( "Filter: \"%s\"... ", ldfi->lfi_filter );
|
||||
fflush( stdout );
|
||||
if ( ldap_search_s( ld, MY_SEARCHBASE, ldfi->lfi_scope,
|
||||
ldfi->lfi_filter, NULL, 0, &result ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_search_s" );
|
||||
return( 1 );
|
||||
} else {
|
||||
found = ldap_count_entries( ld, result );
|
||||
printf( "done. Entries found: %d\n", found ); fflush( stdout );
|
||||
if ( found > 0 ) {
|
||||
/* Matching entries found - break */
|
||||
break;
|
||||
} else {
|
||||
ldap_msgfree( result );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( found == 0 ) {
|
||||
printf( "No matching entries found\n" );
|
||||
} else {
|
||||
printf( "Found %d %s match%s for \"%s\"\n\n", found,
|
||||
ldfi->lfi_desc, found == 1 ? "" : "es", buf );
|
||||
/* for each entry print out name + all attrs and values */
|
||||
for ( e = ldap_first_entry( ld, result ); e != NULL;
|
||||
e = ldap_next_entry( ld, e ) ) {
|
||||
if ( (dn = ldap_get_dn( ld, e )) != NULL ) {
|
||||
printf( "dn: %s\n", dn );
|
||||
ldap_memfree( dn );
|
||||
}
|
||||
for ( a = ldap_first_attribute( ld, e, &ber );
|
||||
a != NULL; a = ldap_next_attribute( ld, e, ber ) ) {
|
||||
if (( vals = ldap_get_values( ld, e, a )) != NULL ) {
|
||||
for ( i = 0; vals[i] != NULL; i++ ) {
|
||||
printf( "%s: %s\n", a, vals[i] );
|
||||
}
|
||||
ldap_value_free( vals );
|
||||
}
|
||||
ldap_memfree( a );
|
||||
}
|
||||
if ( ber != NULL ) {
|
||||
ber_free( ber, 0 );
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
ldap_msgfree( result );
|
||||
}
|
||||
ldap_getfilter_free( ldfp );
|
||||
ldap_unbind( ld );
|
||||
return( 0 );
|
||||
}
|
||||
BIN
mozilla/directory/c-sdk/ldap/examples/macintosh/asearch (2i).68k.u
Executable file
BIN
mozilla/directory/c-sdk/ldap/examples/macintosh/asearch (2i).68k.u
Executable file
Binary file not shown.
BIN
mozilla/directory/c-sdk/ldap/examples/macintosh/asearch (4i).68k.u
Executable file
BIN
mozilla/directory/c-sdk/ldap/examples/macintosh/asearch (4i).68k.u
Executable file
Binary file not shown.
BIN
mozilla/directory/c-sdk/ldap/examples/macintosh/asearch PPC.u
Executable file
BIN
mozilla/directory/c-sdk/ldap/examples/macintosh/asearch PPC.u
Executable file
Binary file not shown.
62
mozilla/directory/c-sdk/ldap/examples/modattrs.c
Normal file
62
mozilla/directory/c-sdk/ldap/examples/modattrs.c
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 1996-1998. Netscape Communications Corporation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Modify an entry:
|
||||
* - replace any existing "mail" attribute values with "babs@airius.com"
|
||||
* - add a new value to the "description" attribute
|
||||
*/
|
||||
|
||||
#include "examples.h"
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
LDAP *ld;
|
||||
LDAPMod mod0, mod1, *mods[ 3 ];
|
||||
char *vals0[ 2 ], *vals1[ 2 ], buf[ 128 ];
|
||||
time_t now;
|
||||
|
||||
/* get an LDAP session handle and authenticate */
|
||||
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
|
||||
perror( "ldap_init" );
|
||||
return( 1 );
|
||||
}
|
||||
if ( ldap_simple_bind_s( ld, MGR_DN, MGR_PW ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_simple_bind_s" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* construct the list of modifications to make */
|
||||
mod0.mod_op = LDAP_MOD_REPLACE;
|
||||
mod0.mod_type = "mail";
|
||||
vals0[0] = "babs@airius.com";
|
||||
vals0[1] = NULL;
|
||||
mod0.mod_values = vals0;
|
||||
|
||||
mod1.mod_op = LDAP_MOD_ADD;
|
||||
mod1.mod_type = "description";
|
||||
time( &now );
|
||||
sprintf( buf, "This entry was modified with the modattrs program on %s",
|
||||
ctime( &now ));
|
||||
/* Get rid of \n which ctime put on the end of the time string */
|
||||
if ( buf[ strlen( buf ) - 1 ] == '\n' ) {
|
||||
buf[ strlen( buf ) - 1 ] = '\0';
|
||||
}
|
||||
vals1[ 0 ] = buf;
|
||||
vals1[ 1 ] = NULL;
|
||||
mod1.mod_values = vals1;
|
||||
|
||||
mods[ 0 ] = &mod0;
|
||||
mods[ 1 ] = &mod1;
|
||||
mods[ 2 ] = NULL;
|
||||
|
||||
/* make the change and clean up after ourselves */
|
||||
if ( ldap_modify_s( ld, ENTRYDN, mods ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_modify_s" );
|
||||
return( 1 );
|
||||
}
|
||||
ldap_unbind( ld );
|
||||
printf( "modification was successful\n" );
|
||||
return( 0 );
|
||||
}
|
||||
148
mozilla/directory/c-sdk/ldap/examples/modrdn.c
Normal file
148
mozilla/directory/c-sdk/ldap/examples/modrdn.c
Normal file
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (c) 1996. Netscape Communications Corporation. All
|
||||
* rights reserved.
|
||||
*
|
||||
* Modify the RDN (relative distinguished name) of an entry. In this
|
||||
* example, we change the dn "cn=Jacques Smith, o=Airius.com"
|
||||
* to "cn=Jacques M Smith, o=Airius.com".
|
||||
*
|
||||
* Since it is an error to either (1) attempt to modrdn an entry which
|
||||
* does not exist, or (2) modrdn an entry where the destination name
|
||||
* already exists, we take some steps, for this example, to make sure
|
||||
* we'll succeed. We (1) add "cn=Jacques Smith" (if the entry exists,
|
||||
* we just ignore the error, and (2) delete "cn=Jacques M Smith" (if the
|
||||
* entry doesn't exist, we ignore the error).
|
||||
*
|
||||
* We pass 0 for the "deleteoldrdn" argument to ldap_modrdn2_s(). This
|
||||
* means that after we change the RDN, the server will put the value
|
||||
* "Jacques Smith" into the cn attribute of the new entry, in addition to
|
||||
* "Jacques M Smith".
|
||||
*/
|
||||
|
||||
#include "examples.h"
|
||||
|
||||
#define NMODS 4
|
||||
|
||||
unsigned long global_counter = 0;
|
||||
|
||||
static void free_mods( LDAPMod **mods );
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
LDAP *ld;
|
||||
char *dn, *ndn, *nrdn;
|
||||
int i;
|
||||
int rc;
|
||||
LDAPMod **mods;
|
||||
|
||||
/* Values we'll use in creating the entry */
|
||||
char *objectclass_values[] = { "top", "person", "organizationalPerson",
|
||||
"inetOrgPerson", NULL };
|
||||
char *cn_values[] = { "Jacques Smith", NULL };
|
||||
char *sn_values[] = { "Smith", NULL };
|
||||
char *givenname_values[] = { "Jacques", NULL };
|
||||
|
||||
/* Specify the DN we're adding */
|
||||
dn = "cn=Jacques Smith, " PEOPLE_BASE; /* see examples.h */
|
||||
/* the destination DN */
|
||||
ndn = "cn=Jacques M Smith, " PEOPLE_BASE; /* see examples.h */
|
||||
/* the new RDN */
|
||||
nrdn = "cn=Jacques M Smith";
|
||||
|
||||
/* get a handle to an LDAP connection */
|
||||
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
|
||||
perror( "ldap_init" );
|
||||
return( 1 );
|
||||
}
|
||||
/* authenticate to the directory as the Directory Manager */
|
||||
if ( ldap_simple_bind_s( ld, MGR_DN, MGR_PW ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_simple_bind_s" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
if (( mods = ( LDAPMod ** ) malloc(( NMODS + 1 ) * sizeof( LDAPMod *)))
|
||||
== NULL ) {
|
||||
fprintf( stderr, "Cannot allocate memory for mods array\n" );
|
||||
return( 1 );
|
||||
}
|
||||
/* Construct the array of values to add */
|
||||
for ( i = 0; i < NMODS; i++ ) {
|
||||
if (( mods[ i ] = ( LDAPMod * ) malloc( sizeof( LDAPMod ))) == NULL ) {
|
||||
fprintf( stderr, "Cannot allocate memory for mods element\n" );
|
||||
return( 1 );
|
||||
}
|
||||
}
|
||||
mods[ 0 ]->mod_op = 0;
|
||||
mods[ 0 ]->mod_type = "objectclass";
|
||||
mods[ 0 ]->mod_values = objectclass_values;
|
||||
mods[ 1 ]->mod_op = 0;
|
||||
mods[ 1 ]->mod_type = "cn";
|
||||
mods[ 1 ]->mod_values = cn_values;
|
||||
mods[ 2 ]->mod_op = 0;
|
||||
mods[ 2 ]->mod_type = "sn";
|
||||
mods[ 2 ]->mod_values = sn_values;
|
||||
mods[ 3 ]->mod_op = 0;
|
||||
mods[ 3 ]->mod_type = "givenname";
|
||||
mods[ 3 ]->mod_values = givenname_values;
|
||||
mods[ 4 ] = NULL;
|
||||
|
||||
|
||||
/* Add the entry */
|
||||
if (( rc = ldap_add_s( ld, dn, mods )) != LDAP_SUCCESS ) {
|
||||
/* If entry exists already, fine. Ignore this error. */
|
||||
if ( rc == LDAP_ALREADY_EXISTS ) {
|
||||
printf( "Entry \"%s is already in the directory.\n", dn );
|
||||
} else {
|
||||
ldap_perror( ld, "ldap_add_s" );
|
||||
free_mods( mods );
|
||||
return( 1 );
|
||||
}
|
||||
} else {
|
||||
printf( "Added entry \"%s\".\n", dn );
|
||||
}
|
||||
free_mods( mods );
|
||||
|
||||
/* Delete the destination entry, for this example */
|
||||
if (( rc = ldap_delete_s( ld, ndn )) != LDAP_SUCCESS ) {
|
||||
/* If entry does not exist, fine. Ignore this error. */
|
||||
if ( rc == LDAP_NO_SUCH_OBJECT ) {
|
||||
printf( "Entry \"%s\" is not in the directory. "
|
||||
"No need to delete.\n", ndn );
|
||||
} else {
|
||||
ldap_perror( ld, "ldap_delete_s" );
|
||||
return( 1 );
|
||||
}
|
||||
} else {
|
||||
printf( "Deleted entry \"%s\".\n", ndn );
|
||||
}
|
||||
|
||||
/* Do the modrdn operation */
|
||||
if ( ldap_modrdn2_s( ld, dn, nrdn, 0 ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_modrdn2_s" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
printf( "The modrdn operation was successful. Entry\n"
|
||||
"\"%s\" has been changed to\n"
|
||||
"\"%s\".\n", dn, ndn );
|
||||
|
||||
ldap_unbind( ld );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Free a mods array.
|
||||
*/
|
||||
static void
|
||||
free_mods( LDAPMod **mods )
|
||||
{
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < NMODS; i++ ) {
|
||||
free( mods[ i ] );
|
||||
}
|
||||
free( mods );
|
||||
}
|
||||
143
mozilla/directory/c-sdk/ldap/examples/nsprio.c
Normal file
143
mozilla/directory/c-sdk/ldap/examples/nsprio.c
Normal file
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (c) 2000. Netscape Communications Corporation. All
|
||||
* rights reserved.
|
||||
*
|
||||
* A version of asearch.c that uses NSPR (Netscape Portable Runtime) I/O.
|
||||
*
|
||||
* Search the directory for all people whose surname (last name) is
|
||||
* "Jensen". Since the "sn" attribute is a caseignorestring (cis), case
|
||||
* is not significant when searching.
|
||||
*
|
||||
* Instead of calling the synchronous ldap_search_s() routine, we call
|
||||
* the asynchronous routine ldap_search() and poll for results using
|
||||
* ldap_result().
|
||||
*
|
||||
*/
|
||||
|
||||
#include "examples.h"
|
||||
#include <nspr.h>
|
||||
#include <ldappr.h>
|
||||
|
||||
static void do_other_work();
|
||||
|
||||
unsigned long global_counter = 0;
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
LDAP *ld;
|
||||
LDAPMessage *result, *e;
|
||||
BerElement *ber;
|
||||
char *a, *dn;
|
||||
char **vals;
|
||||
int i;
|
||||
int rc;
|
||||
int finished;
|
||||
int msgid;
|
||||
int num_entries = 0;
|
||||
struct timeval zerotime;
|
||||
|
||||
zerotime.tv_sec = zerotime.tv_usec = 0L;
|
||||
|
||||
if ( prldap_install_routines( NULL, 1 /* shared */ ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( NULL, "prldap_install_routines" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* get a handle to an LDAP connection */
|
||||
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
|
||||
perror( "ldap_init" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* authenticate to the directory as nobody */
|
||||
if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_simple_bind_s" );
|
||||
return( 1 );
|
||||
}
|
||||
/* search for all entries with surname of Jensen */
|
||||
if (( msgid = ldap_search( ld, MY_SEARCHBASE, LDAP_SCOPE_SUBTREE,
|
||||
MY_FILTER, NULL, 0 )) < 0 ) {
|
||||
ldap_perror( ld, "ldap_search" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* Loop, polling for results until finished */
|
||||
finished = 0;
|
||||
while ( !finished ) {
|
||||
/*
|
||||
* Poll for results. We call ldap_result with the "all" argument
|
||||
* set to LDAP_MSG_ONE. This causes ldap_result() to return exactly one
|
||||
* entry if at least one entry is available. This allows us to
|
||||
* display the entries as they are received.
|
||||
*/
|
||||
result = NULL;
|
||||
rc = ldap_result( ld, msgid, LDAP_MSG_ONE, &zerotime, &result );
|
||||
switch ( rc ) {
|
||||
case -1:
|
||||
/* some error occurred */
|
||||
ldap_perror( ld, "ldap_result" );
|
||||
return( 1 );
|
||||
case 0:
|
||||
/* Timeout was exceeded. No entries are ready for retrieval. */
|
||||
if ( result != NULL ) {
|
||||
ldap_msgfree( result );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/*
|
||||
* Either an entry is ready for retrieval, or all entries have
|
||||
* been retrieved.
|
||||
*/
|
||||
if (( e = ldap_first_entry( ld, result )) == NULL ) {
|
||||
/* All done */
|
||||
finished = 1;
|
||||
if ( result != NULL ) {
|
||||
ldap_msgfree( result );
|
||||
}
|
||||
continue;
|
||||
}
|
||||
/* for each entry print out name + all attrs and values */
|
||||
num_entries++;
|
||||
if (( dn = ldap_get_dn( ld, e )) != NULL ) {
|
||||
printf( "dn: %s\n", dn );
|
||||
ldap_memfree( dn );
|
||||
}
|
||||
for ( a = ldap_first_attribute( ld, e, &ber );
|
||||
a != NULL; a = ldap_next_attribute( ld, e, ber ) ) {
|
||||
if (( vals = ldap_get_values( ld, e, a )) != NULL ) {
|
||||
for ( i = 0; vals[ i ] != NULL; i++ ) {
|
||||
printf( "%s: %s\n", a, vals[ i ] );
|
||||
}
|
||||
ldap_value_free( vals );
|
||||
}
|
||||
ldap_memfree( a );
|
||||
}
|
||||
if ( ber != NULL ) {
|
||||
ber_free( ber, 0 );
|
||||
}
|
||||
printf( "\n" );
|
||||
ldap_msgfree( result );
|
||||
}
|
||||
/* Do other work here while you are waiting... */
|
||||
do_other_work();
|
||||
}
|
||||
|
||||
/* All done. Print a summary. */
|
||||
printf( "%d entries retrieved. I counted to %ld "
|
||||
"while I was waiting.\n", num_entries,
|
||||
global_counter );
|
||||
ldap_unbind( ld );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Perform other work while polling for results. This doesn't do anything
|
||||
* useful, but it could.
|
||||
*/
|
||||
static void
|
||||
do_other_work()
|
||||
{
|
||||
global_counter++;
|
||||
}
|
||||
191
mozilla/directory/c-sdk/ldap/examples/ppolicy.c
Normal file
191
mozilla/directory/c-sdk/ldap/examples/ppolicy.c
Normal file
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* Copyright (c) 1998. Netscape Communications Corporation. All
|
||||
* rights reserved.
|
||||
*
|
||||
* Attempt to bind to the directory, and report back any password
|
||||
* expiration information received.
|
||||
*/
|
||||
#include "examples.h"
|
||||
|
||||
#define NO_PASSWORD_CONTROLS 0
|
||||
#define PASSWORD_EXPIRED -1
|
||||
|
||||
static void doUsage() {
|
||||
printf( "Usage: ppolicy HOST PORT DN PASSWORD\n" );
|
||||
}
|
||||
|
||||
static int
|
||||
check_controls( LDAPControl **ctrls ) {
|
||||
int i;
|
||||
char buf[256];
|
||||
int status = NO_PASSWORD_CONTROLS;
|
||||
|
||||
if ( ctrls == NULL ) {
|
||||
return NO_PASSWORD_CONTROLS;
|
||||
}
|
||||
|
||||
for ( i = 0; ctrls[ i ] != NULL; ++i ) {
|
||||
memcpy( buf, ctrls[ i ]->ldctl_value.bv_val,
|
||||
ctrls[ i ]->ldctl_value.bv_len );
|
||||
buf[ctrls[ i ]->ldctl_value.bv_len] = 0;
|
||||
if( !strcmp( LDAP_CONTROL_PWEXPIRED, ctrls[ i ]->ldctl_oid ) ) {
|
||||
status = PASSWORD_EXPIRED;
|
||||
} else if ( !strcmp( LDAP_CONTROL_PWEXPIRING,
|
||||
ctrls[ i ]->ldctl_oid ) ) {
|
||||
status = atoi( buf );
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static void
|
||||
process_other_errors( int lderr ) {
|
||||
fprintf( stderr, "ldap_parse_result: %s",
|
||||
ldap_err2string( lderr ));
|
||||
if ( LDAP_CONNECT_ERROR == lderr ) {
|
||||
perror( " - " );
|
||||
} else {
|
||||
fputc( '\n', stderr );
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
process_other_messages( char *errmsg ) {
|
||||
if ( errmsg != NULL ) {
|
||||
if ( *errmsg != '\0' ) {
|
||||
fprintf( stderr, "Additional info: %s\n",
|
||||
errmsg );
|
||||
}
|
||||
ldap_memfree( errmsg );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main( int argc, char **argv ) {
|
||||
LDAP *ld;
|
||||
char *dn;
|
||||
char *password;
|
||||
char *host;
|
||||
int port;
|
||||
int rc = 0;
|
||||
int version = LDAP_VERSION3;
|
||||
int msgid;
|
||||
LDAPMessage *result;
|
||||
LDAPControl **ctrls;
|
||||
int lderr;
|
||||
int password_status = 0;
|
||||
char *matcheddn, *errmsg, **refs;
|
||||
|
||||
if ( argc == 1 ) {
|
||||
host = MY_HOST;
|
||||
port = MY_PORT;
|
||||
dn = USER_DN;
|
||||
password = USER_PW;
|
||||
} else if ( argc == 5 ) {
|
||||
host = argv[1];
|
||||
port = atoi( argv[2] );
|
||||
dn = argv[3];
|
||||
password = argv[4];
|
||||
} else {
|
||||
doUsage();
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* get a handle to an LDAP connection */
|
||||
if ( (ld = ldap_init( host, port )) == NULL ) {
|
||||
perror( "ldap_init" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
if (ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ) != 0) {
|
||||
ldap_perror( ld, "ldap_set_option");
|
||||
return ( 1 );
|
||||
}
|
||||
|
||||
/* authenticate to the directory */
|
||||
#ifdef SYNCHRONOUS_BIND
|
||||
/* Synchronous bind */
|
||||
ldap_simple_bind_s( ld, dn, password );
|
||||
lderr = ldap_get_lderrno( ld, NULL, &errmsg );
|
||||
if ( LDAP_SUCCESS == lderr ) {
|
||||
printf( "Authentication successful\n" );
|
||||
} else {
|
||||
rc = -1;
|
||||
if ( LDAP_INVALID_CREDENTIALS == lderr ) {
|
||||
fprintf( stderr, "Invalid credentials\n" );
|
||||
} else {
|
||||
process_other_errors( lderr );
|
||||
}
|
||||
if ( errmsg != NULL ) {
|
||||
if ( strstr( errmsg, "password expired" ) != NULL ) {
|
||||
fprintf( stderr, "Password expired\n" );
|
||||
} else {
|
||||
fprintf( stderr, "Additional info: %s\n",
|
||||
errmsg );
|
||||
}
|
||||
ldap_memfree( errmsg );
|
||||
}
|
||||
}
|
||||
/* You can't get the controls with a synchronous bind, so we
|
||||
can't report if the password is about to expire */
|
||||
|
||||
#else
|
||||
/* Asynchronous bind */
|
||||
if ( msgid = ldap_simple_bind( ld, dn, password ) < 0 ) {
|
||||
ldap_perror( ld, "ldap_simple_bind" );
|
||||
rc = -1;
|
||||
} else {
|
||||
rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ONE,
|
||||
(struct timeval *)NULL, &result );
|
||||
if ( rc == LDAP_RES_BIND ) {
|
||||
if ( ldap_parse_result( ld, result, &lderr, &matcheddn, &errmsg,
|
||||
&refs, &ctrls, 0 ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_parse_result" );
|
||||
} else {
|
||||
if ( LDAP_SUCCESS == lderr ) {
|
||||
printf( "Authentication successful\n" );
|
||||
} else {
|
||||
if ( LDAP_INVALID_CREDENTIALS == lderr ) {
|
||||
fprintf( stderr, "Invalid credentials\n" );
|
||||
} else {
|
||||
process_other_errors( lderr );
|
||||
}
|
||||
if ( errmsg != NULL ) {
|
||||
if ( strstr( errmsg, "password expired" ) != NULL ) {
|
||||
fprintf( stderr, "Password expired\n" );
|
||||
} else {
|
||||
fprintf( stderr, "Additional info: %s\n",
|
||||
errmsg );
|
||||
}
|
||||
ldap_memfree( errmsg );
|
||||
}
|
||||
}
|
||||
|
||||
password_status = check_controls( ctrls );
|
||||
ldap_controls_free( ctrls );
|
||||
if ( password_status == PASSWORD_EXPIRED ) {
|
||||
fprintf( stderr,
|
||||
"Password expired and must be reset\n" );
|
||||
} else if ( password_status > 0 ) {
|
||||
fprintf( stderr,
|
||||
"Password will expire in %d seconds\n",
|
||||
password_status );
|
||||
}
|
||||
rc = 0;
|
||||
}
|
||||
} else {
|
||||
fprintf( stderr, "ldap_result returned %d\n", rc );
|
||||
ldap_perror( ld, "ldap_result" );
|
||||
rc = -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( LDAP_SUCCESS == lderr ) {
|
||||
ldap_unbind( ld );
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
193
mozilla/directory/c-sdk/ldap/examples/psearch.c
Normal file
193
mozilla/directory/c-sdk/ldap/examples/psearch.c
Normal file
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* Copyright (c) 2000. Netscape Communications Corporation. All
|
||||
* rights reserved.
|
||||
*
|
||||
* Use a Persistent Search to monitor the directory server for changes to
|
||||
* all people entries whose surname (last name) is "Jensen".
|
||||
*
|
||||
*/
|
||||
|
||||
#include "examples.h"
|
||||
|
||||
static char *changetype_num2string( int chgtype );
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
LDAP *ld;
|
||||
LDAPMessage *result, *e;
|
||||
BerElement *ber;
|
||||
char *a, *dn;
|
||||
char **vals;
|
||||
int i;
|
||||
int rc;
|
||||
int finished;
|
||||
int msgid;
|
||||
int num_entries = 0;
|
||||
int version = LDAP_VERSION3;
|
||||
LDAPControl *ctrls[2], *psctrl, **ectrls;
|
||||
|
||||
/* arrange to use LDAP version 3 */
|
||||
if ( ldap_set_option( NULL, LDAP_OPT_PROTOCOL_VERSION, &version ) != 0 ) {
|
||||
perror( "ldap_set_option" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* get a handle to an LDAP connection */
|
||||
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
|
||||
perror( "ldap_init" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* authenticate to the directory as nobody */
|
||||
if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_simple_bind_s" );
|
||||
ldap_unbind( ld );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* construct the Persistent Search control */
|
||||
if ( ldap_create_persistentsearch_control( ld, LDAP_CHANGETYPE_ANY,
|
||||
1 /* changesOnly */, 1 /* request entry change controls */,
|
||||
1 /* critical */, &psctrl ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_create_persistentsearch_control" );
|
||||
ldap_unbind( ld );
|
||||
return( 1 );
|
||||
}
|
||||
ctrls[0] = psctrl;
|
||||
ctrls[1] = NULL;
|
||||
|
||||
/* issue a persistent search for all entries with surname of Jensen */
|
||||
if ( LDAP_SUCCESS != ldap_search_ext( ld, MY_SEARCHBASE,
|
||||
LDAP_SCOPE_SUBTREE, MY_FILTER, NULL /* all attrs */,
|
||||
0 /* get attrs and values */, ctrls, NULL /* no client ctrls */,
|
||||
NULL /* no timeout */, 0 /* no sizelimit */, &msgid )) {
|
||||
ldap_perror( ld, "ldap_search_ext" );
|
||||
ldap_unbind( ld );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
ldap_control_free( psctrl ); /* no longer needed */
|
||||
|
||||
/*
|
||||
* Loop, polling for results until finished.
|
||||
* Since this is a persistent search, this loop won't end until the
|
||||
* server shuts down or we lose the connection for some other reason.
|
||||
* We could abandon the persistent search or close the connection of
|
||||
* course, but we don't in this example.
|
||||
*/
|
||||
finished = 0;
|
||||
while ( !finished ) {
|
||||
/*
|
||||
* Poll for results. We call ldap_result with the "all" argument
|
||||
* set to LDAP_MSG_ONE. This causes ldap_result() to return exactly one
|
||||
* entry if at least one entry is available. This allows us to
|
||||
* display the entries as they are received.
|
||||
*/
|
||||
result = NULL;
|
||||
rc = ldap_result( ld, msgid, LDAP_MSG_ONE, NULL /* no timeout */, &result );
|
||||
switch ( rc ) {
|
||||
case -1:
|
||||
/* some error occurred */
|
||||
ldap_perror( ld, "ldap_result" );
|
||||
ldap_unbind( ld );
|
||||
return( 1 );
|
||||
case 0:
|
||||
/* Timeout was exceeded. No entries are ready for retrieval. */
|
||||
if ( result != NULL ) {
|
||||
ldap_msgfree( result );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/*
|
||||
* Either an entry is ready for retrieval, or all entries have
|
||||
* been retrieved.
|
||||
*/
|
||||
if (( e = ldap_first_entry( ld, result )) == NULL ) {
|
||||
/* All done */
|
||||
finished = 1;
|
||||
if ( result != NULL ) {
|
||||
ldap_msgfree( result );
|
||||
}
|
||||
continue;
|
||||
}
|
||||
num_entries++;
|
||||
|
||||
/* for each entry print out name */
|
||||
if (( dn = ldap_get_dn( ld, e )) != NULL ) {
|
||||
printf( "dn: %s\n", dn );
|
||||
ldap_memfree( dn );
|
||||
}
|
||||
|
||||
/* print entry change info. if it was returned */
|
||||
if ( LDAP_SUCCESS == ldap_get_entry_controls( ld, e, &ectrls )) {
|
||||
int chgtype, chgnumpresent;
|
||||
long chgnum;
|
||||
char *prevdn;
|
||||
|
||||
if ( LDAP_SUCCESS == ldap_parse_entrychange_control( ld,
|
||||
ectrls, &chgtype, &prevdn, &chgnumpresent, &chgnum )) {
|
||||
printf( "changeType: %s\n",
|
||||
changetype_num2string( chgtype ));
|
||||
if ( prevdn != NULL ) {
|
||||
printf( "previousDN: %s\n", prevdn );
|
||||
ldap_memfree( prevdn );
|
||||
}
|
||||
if ( chgnumpresent ) {
|
||||
printf( "changeNumber: %d\n", chgnum );
|
||||
}
|
||||
ldap_controls_free( ectrls );
|
||||
}
|
||||
}
|
||||
|
||||
/* print out all attrs and values */
|
||||
for ( a = ldap_first_attribute( ld, e, &ber );
|
||||
a != NULL; a = ldap_next_attribute( ld, e, ber ) ) {
|
||||
if (( vals = ldap_get_values( ld, e, a )) != NULL ) {
|
||||
for ( i = 0; vals[ i ] != NULL; i++ ) {
|
||||
printf( "%s: %s\n", a, vals[ i ] );
|
||||
}
|
||||
ldap_value_free( vals );
|
||||
}
|
||||
ldap_memfree( a );
|
||||
}
|
||||
if ( ber != NULL ) {
|
||||
ber_free( ber, 0 );
|
||||
}
|
||||
printf( "\n" );
|
||||
ldap_msgfree( result );
|
||||
}
|
||||
}
|
||||
|
||||
/* All done. Print a summary. */
|
||||
printf( "%d entries retrieved.\n", num_entries );
|
||||
ldap_unbind( ld );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
changetype_num2string( int chgtype )
|
||||
{
|
||||
static char buf[ 25 ];
|
||||
char *s;
|
||||
|
||||
switch( chgtype ) {
|
||||
case LDAP_CHANGETYPE_ADD:
|
||||
s = "add";
|
||||
break;
|
||||
case LDAP_CHANGETYPE_DELETE:
|
||||
s = "delete";
|
||||
break;
|
||||
case LDAP_CHANGETYPE_MODIFY:
|
||||
s = "modify";
|
||||
break;
|
||||
case LDAP_CHANGETYPE_MODDN:
|
||||
s = "moddn";
|
||||
break;
|
||||
default:
|
||||
sprintf( s, "unknown (%d)", chgtype );
|
||||
}
|
||||
|
||||
return( s );
|
||||
}
|
||||
63
mozilla/directory/c-sdk/ldap/examples/rdentry.c
Normal file
63
mozilla/directory/c-sdk/ldap/examples/rdentry.c
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 1996. Netscape Communications Corporation. All
|
||||
* rights reserved.
|
||||
*
|
||||
* Search the directory for the specific entry ENTRYDN (defined in examples.h)
|
||||
* Retrieve all attributes from the entry.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "examples.h"
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
LDAP *ld;
|
||||
LDAPMessage *result, *e;
|
||||
BerElement *ber;
|
||||
char *a, *dn;
|
||||
char **vals;
|
||||
int i;
|
||||
|
||||
/* get a handle to an LDAP connection */
|
||||
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
|
||||
perror( "ldap_init" );
|
||||
return( 1 );
|
||||
}
|
||||
/* authenticate to the directory as nobody */
|
||||
if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_simple_bind_s" );
|
||||
return( 1 );
|
||||
}
|
||||
/* search for Babs' entry */
|
||||
if ( ldap_search_s( ld, ENTRYDN, LDAP_SCOPE_SUBTREE,
|
||||
"(objectclass=*)", NULL, 0, &result ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_search_s" );
|
||||
return( 1 );
|
||||
}
|
||||
/* for each entry print out name + all attrs and values */
|
||||
for ( e = ldap_first_entry( ld, result ); e != NULL;
|
||||
e = ldap_next_entry( ld, e ) ) {
|
||||
if ( (dn = ldap_get_dn( ld, e )) != NULL ) {
|
||||
printf( "dn: %s\n", dn );
|
||||
ldap_memfree( dn );
|
||||
}
|
||||
for ( a = ldap_first_attribute( ld, e, &ber );
|
||||
a != NULL; a = ldap_next_attribute( ld, e, ber ) ) {
|
||||
if ((vals = ldap_get_values( ld, e, a)) != NULL ) {
|
||||
for ( i = 0; vals[i] != NULL; i++ ) {
|
||||
printf( "%s: %s\n", a, vals[i] );
|
||||
}
|
||||
ldap_value_free( vals );
|
||||
}
|
||||
ldap_memfree( a );
|
||||
}
|
||||
if ( ber != NULL ) {
|
||||
ber_free( ber, 0 );
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
ldap_msgfree( result );
|
||||
ldap_unbind( ld );
|
||||
return( 0 );
|
||||
}
|
||||
68
mozilla/directory/c-sdk/ldap/examples/search.c
Normal file
68
mozilla/directory/c-sdk/ldap/examples/search.c
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 1996. Netscape Communications Corporation. All
|
||||
* rights reserved.
|
||||
*
|
||||
* Search the directory for all people whose surname (last name) is
|
||||
* "Jensen". Since the "sn" attribute is a caseignorestring (cis), case
|
||||
* is not significant when searching.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "examples.h"
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
LDAP *ld;
|
||||
LDAPMessage *result, *e;
|
||||
BerElement *ber;
|
||||
char *a, *dn;
|
||||
char **vals;
|
||||
int i;
|
||||
|
||||
/* get a handle to an LDAP connection */
|
||||
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
|
||||
perror( "ldap_init" );
|
||||
return( 1 );
|
||||
}
|
||||
/* authenticate to the directory as nobody */
|
||||
if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_simple_bind_s" );
|
||||
ldap_unbind( ld );
|
||||
return( 1 );
|
||||
}
|
||||
/* search for all entries with surname of Jensen */
|
||||
if ( ldap_search_s( ld, MY_SEARCHBASE, LDAP_SCOPE_SUBTREE,
|
||||
MY_FILTER, NULL, 0, &result ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_search_s" );
|
||||
if ( result == NULL ) {
|
||||
ldap_unbind( ld );
|
||||
return( 1 );
|
||||
}
|
||||
}
|
||||
/* for each entry print out name + all attrs and values */
|
||||
for ( e = ldap_first_entry( ld, result ); e != NULL;
|
||||
e = ldap_next_entry( ld, e ) ) {
|
||||
if ( (dn = ldap_get_dn( ld, e )) != NULL ) {
|
||||
printf( "dn: %s\n", dn );
|
||||
ldap_memfree( dn );
|
||||
}
|
||||
for ( a = ldap_first_attribute( ld, e, &ber );
|
||||
a != NULL; a = ldap_next_attribute( ld, e, ber ) ) {
|
||||
if ((vals = ldap_get_values( ld, e, a)) != NULL ) {
|
||||
for ( i = 0; vals[i] != NULL; i++ ) {
|
||||
printf( "%s: %s\n", a, vals[i] );
|
||||
}
|
||||
ldap_value_free( vals );
|
||||
}
|
||||
ldap_memfree( a );
|
||||
}
|
||||
if ( ber != NULL ) {
|
||||
ber_free( ber, 0 );
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
ldap_msgfree( result );
|
||||
ldap_unbind( ld );
|
||||
return( 0 );
|
||||
}
|
||||
145
mozilla/directory/c-sdk/ldap/examples/srvrsort.c
Normal file
145
mozilla/directory/c-sdk/ldap/examples/srvrsort.c
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (c) 1999. Netscape Communications Corporation. All
|
||||
* rights reserved.
|
||||
*
|
||||
* Search the directory for all people. Ask the server to sort the entries
|
||||
* first by sn (last name) and then in reverse order by givenname (first name).
|
||||
*/
|
||||
|
||||
#include "examples.h"
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
LDAP *ld;
|
||||
LDAPMessage *result, *e;
|
||||
char *attrfail, *matched = NULL, *errmsg = NULL;
|
||||
char **vals, **referrals;
|
||||
int rc, parse_rc, version;
|
||||
unsigned long sortrc;
|
||||
LDAPControl *sortctrl = NULL;
|
||||
LDAPControl *requestctrls[ 2 ];
|
||||
LDAPControl **resultctrls = NULL;
|
||||
LDAPsortkey **sortkeylist;
|
||||
|
||||
/* Arrange for all connections to use LDAPv3 */
|
||||
version = LDAP_VERSION3;
|
||||
if ( ldap_set_option( NULL, LDAP_OPT_PROTOCOL_VERSION, &version )
|
||||
!= 0 ) {
|
||||
fprintf( stderr,
|
||||
"ldap_set_option protocol version to %d failed\n",
|
||||
version );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* Get a handle to an LDAP connection */
|
||||
if ( (ld = ldap_init( MY_HOST, MY_PORT ) ) == NULL ) {
|
||||
perror( "ldap_init" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* Authenticate as Directory Manager */
|
||||
if ( ldap_simple_bind_s( ld, MGR_DN, MGR_PW ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_simple_bind_s" );
|
||||
ldap_unbind( ld );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a sort key list that specifies the sort order of the results.
|
||||
* Sort the results by last name first, then by first name.
|
||||
*/
|
||||
ldap_create_sort_keylist( &sortkeylist, "description -givenname" );
|
||||
|
||||
/* Create the sort control. */
|
||||
rc = ldap_create_sort_control( ld, sortkeylist, 1, &sortctrl );
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
fprintf( stderr, "ldap_create_sort_control: %s\n",
|
||||
ldap_err2string( rc ) );
|
||||
ldap_unbind( ld );
|
||||
return( 1 );
|
||||
}
|
||||
requestctrls[ 0 ] = sortctrl;
|
||||
requestctrls[ 1 ] = NULL;
|
||||
|
||||
/* Search for all entries in Sunnyvale */
|
||||
|
||||
rc = ldap_search_ext_s( ld, "o=Airius.com", LDAP_SCOPE_SUBTREE,
|
||||
"(objectclass=person)", NULL, 0, requestctrls, NULL, NULL, 0,
|
||||
&result );
|
||||
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
fprintf( stderr, "ldap_search_ext_s: %s\n",
|
||||
ldap_err2string( rc ) );
|
||||
ldap_unbind( ld );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
parse_rc = ldap_parse_result( ld, result, &rc, &matched, &errmsg,
|
||||
&referrals, &resultctrls, 0 );
|
||||
|
||||
if ( parse_rc != LDAP_SUCCESS ) {
|
||||
fprintf( stderr, "ldap_parse_result: %s\n",
|
||||
ldap_err2string( parse_rc ) );
|
||||
ldap_unbind( ld );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
fprintf( stderr, "ldap_search_ext_s: %s\n",
|
||||
ldap_err2string( rc ) );
|
||||
if ( errmsg != NULL && *errmsg != '\0' ) {
|
||||
fprintf( stderr, "%s\n", errmsg );
|
||||
}
|
||||
|
||||
ldap_unbind( ld );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
parse_rc = ldap_parse_sort_control( ld, resultctrls, &sortrc,
|
||||
&attrfail );
|
||||
|
||||
if ( parse_rc != LDAP_SUCCESS ) {
|
||||
fprintf( stderr, "ldap_parse_sort_control: %s\n",
|
||||
ldap_err2string( parse_rc ) );
|
||||
ldap_unbind( ld );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
if ( sortrc != LDAP_SUCCESS ) {
|
||||
fprintf( stderr, "Sort error: %s\n", ldap_err2string( sortrc ));
|
||||
if ( attrfail != NULL && *attrfail != '\0' ) {
|
||||
fprintf( stderr, "Bad attribute: %s\n", attrfail);
|
||||
}
|
||||
ldap_unbind( ld );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* for each entry print out name + all attrs and values */
|
||||
for ( e = ldap_first_entry( ld, result ); e != NULL;
|
||||
e = ldap_next_entry( ld, e ) ) {
|
||||
if ((vals = ldap_get_values( ld, e, "sn")) != NULL ) {
|
||||
if ( vals[0] != NULL ) {
|
||||
printf( "%s", vals[0] );
|
||||
}
|
||||
ldap_value_free( vals );
|
||||
}
|
||||
|
||||
if ((vals = ldap_get_values( ld, e, "givenname")) != NULL ) {
|
||||
if ( vals[0] != NULL ) {
|
||||
printf( "\t%s", vals[0] );
|
||||
}
|
||||
ldap_value_free( vals );
|
||||
}
|
||||
|
||||
putchar( '\n' );
|
||||
}
|
||||
|
||||
ldap_msgfree( result );
|
||||
ldap_free_sort_keylist( sortkeylist );
|
||||
ldap_control_free( sortctrl );
|
||||
ldap_controls_free( resultctrls );
|
||||
ldap_unbind( ld );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
102
mozilla/directory/c-sdk/ldap/examples/ssearch.c
Normal file
102
mozilla/directory/c-sdk/ldap/examples/ssearch.c
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2000. Netscape Communications Corporation. All
|
||||
* rights reserved.
|
||||
*
|
||||
* Use an SSL connection to search the directory for all people whose
|
||||
* surname (last name) is "Jensen". Since the "sn" attribute is a
|
||||
* caseignorestring (cis), case is not significant when searching.
|
||||
*
|
||||
* Authenticate using a client certificate.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "examples.h"
|
||||
#include "ldap_ssl.h"
|
||||
|
||||
#define MY_CERTDB "/usr/netscape4/alias/client-cert.db"
|
||||
#define MY_KEYDB "/usr/netscape4/alias/client-key.db"
|
||||
#define MY_KEYNICKNAME "Server-Key"
|
||||
#define MY_CERTNICKNAME "Server-Cert"
|
||||
#define MY_KEYPASSWD "secret"
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
LDAP *ld;
|
||||
LDAPMessage *result, *e;
|
||||
BerElement *ber;
|
||||
char *a, *dn;
|
||||
char **vals;
|
||||
int i;
|
||||
|
||||
/* Initialize the client */
|
||||
if ( ldapssl_clientauth_init( MY_CERTDB, NULL, 1 /* need key db */,
|
||||
MY_KEYDB, NULL ) < 0 ) {
|
||||
perror( "ldapssl_clientauth_init" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* get a handle to an LDAP connection */
|
||||
if ( (ld = ldapssl_init( MY_HOST, MY_SSL_PORT, 1 )) == NULL ) {
|
||||
perror( "ldapssl_init" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* use LDAPv3 */
|
||||
i = LDAP_VERSION3;
|
||||
if ( ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &i ) < 0 ) {
|
||||
ldap_perror( ld, "ldap_set_option LDAPv3" );
|
||||
ldap_unbind( ld );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* enable certificate-based client authentication. */
|
||||
if ( ldapssl_enable_clientauth( ld, MY_KEYNICKNAME, MY_KEYPASSWD,
|
||||
MY_CERTNICKNAME ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldapssl_enable_clientauth" );
|
||||
ldap_unbind( ld );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
if ( ldap_sasl_bind_s( ld, NULL, LDAP_SASL_EXTERNAL, NULL, NULL, NULL,
|
||||
NULL ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_sasl_bind_s EXTERNAL" );
|
||||
ldap_unbind( ld );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* search for all entries with surname of Jensen */
|
||||
if ( ldap_search_s( ld, "o=Airius.com", LDAP_SCOPE_SUBTREE,
|
||||
"(sn=jensen)", NULL, 0, &result ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_search_s" );
|
||||
if ( result == NULL ) {
|
||||
ldap_unbind( ld );
|
||||
return( 1 );
|
||||
}
|
||||
}
|
||||
/* for each entry print out name + all attrs and values */
|
||||
for ( e = ldap_first_entry( ld, result ); e != NULL;
|
||||
e = ldap_next_entry( ld, e ) ) {
|
||||
if ( (dn = ldap_get_dn( ld, e )) != NULL ) {
|
||||
printf( "dn: %s\n", dn );
|
||||
ldap_memfree( dn );
|
||||
}
|
||||
for ( a = ldap_first_attribute( ld, e, &ber );
|
||||
a != NULL; a = ldap_next_attribute( ld, e, ber ) ) {
|
||||
if ((vals = ldap_get_values( ld, e, a)) != NULL ) {
|
||||
for ( i = 0; vals[i] != NULL; i++ ) {
|
||||
printf( "%s: %s\n", a, vals[i] );
|
||||
}
|
||||
ldap_value_free( vals );
|
||||
}
|
||||
ldap_memfree( a );
|
||||
}
|
||||
if ( ber != NULL ) {
|
||||
ber_free( ber, 0 );
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
ldap_msgfree( result );
|
||||
ldap_unbind( ld );
|
||||
return( 0 );
|
||||
}
|
||||
80
mozilla/directory/c-sdk/ldap/examples/ssnoauth.c
Normal file
80
mozilla/directory/c-sdk/ldap/examples/ssnoauth.c
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2000. Netscape Communications Corporation. All
|
||||
* rights reserved.
|
||||
*
|
||||
* Use an SSL connection to search the directory for all people whose
|
||||
* surname (last name) is "Jensen". Since the "sn" attribute is a
|
||||
* caseignorestring (cis), case is not significant when searching.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "examples.h"
|
||||
#include "ldap_ssl.h"
|
||||
|
||||
#define MY_CERTDB "/usr/netscape4/alias/client-cert.db"
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
LDAP *ld;
|
||||
LDAPMessage *result, *e;
|
||||
BerElement *ber;
|
||||
char *a, *dn;
|
||||
char **vals;
|
||||
int i;
|
||||
|
||||
/* Initialize the client */
|
||||
if ( ldapssl_client_init( MY_CERTDB, NULL ) < 0 ) {
|
||||
perror( "ldapssl_client_init" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* get a handle to an LDAP connection */
|
||||
if ( (ld = ldapssl_init( MY_HOST, MY_PORT, 1 )) == NULL ) {
|
||||
perror( "ldapssl_init" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* use LDAPv3 */
|
||||
i = LDAP_VERSION3;
|
||||
if ( ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &i ) < 0 ) {
|
||||
ldap_perror( ld, "ldap_set_option LDAPv3" );
|
||||
ldap_unbind( ld );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* search for all entries with surname of Jensen */
|
||||
if ( ldap_search_s( ld, "o=Airius.com", LDAP_SCOPE_SUBTREE,
|
||||
"(sn=jensen)", NULL, 0, &result ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_search_s" );
|
||||
if ( result == NULL ) {
|
||||
ldap_unbind( ld );
|
||||
return( 1 );
|
||||
}
|
||||
}
|
||||
/* for each entry print out name + all attrs and values */
|
||||
for ( e = ldap_first_entry( ld, result ); e != NULL;
|
||||
e = ldap_next_entry( ld, e ) ) {
|
||||
if ( (dn = ldap_get_dn( ld, e )) != NULL ) {
|
||||
printf( "dn: %s\n", dn );
|
||||
ldap_memfree( dn );
|
||||
}
|
||||
for ( a = ldap_first_attribute( ld, e, &ber );
|
||||
a != NULL; a = ldap_next_attribute( ld, e, ber ) ) {
|
||||
if ((vals = ldap_get_values( ld, e, a)) != NULL ) {
|
||||
for ( i = 0; vals[i] != NULL; i++ ) {
|
||||
printf( "%s: %s\n", a, vals[i] );
|
||||
}
|
||||
ldap_value_free( vals );
|
||||
}
|
||||
ldap_memfree( a );
|
||||
}
|
||||
if ( ber != NULL ) {
|
||||
ber_free( ber, 0 );
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
ldap_msgfree( result );
|
||||
ldap_unbind( ld );
|
||||
return( 0 );
|
||||
}
|
||||
124
mozilla/directory/c-sdk/ldap/examples/win32.mak
Normal file
124
mozilla/directory/c-sdk/ldap/examples/win32.mak
Normal file
@@ -0,0 +1,124 @@
|
||||
#
|
||||
# Copyright (c) 1996-1998. Netscape Communications Corporation. All
|
||||
# rights reserved.
|
||||
#
|
||||
#
|
||||
# Win32 GNU Makefile for Directory SDK examples
|
||||
#
|
||||
# build all the examples by typing: gmake -f win32.mak
|
||||
#
|
||||
|
||||
###############################################################################
|
||||
# Note that the LDAP API library has different names for the SSL-enabled
|
||||
# and non-SSL versions of the Directory SDK for C:
|
||||
#
|
||||
# o In the SSL-enabled version, the import library for Microsoft
|
||||
# compilers is named nsldapssl32v41.lib, and the DLL is named
|
||||
# nsldapssl32v41.dll.
|
||||
#
|
||||
# o In the non-SSL version, the import library for Microsoft
|
||||
# compilers is named nsldap32v41.lib, and the DLL is named
|
||||
# nsldap32v41.dll.
|
||||
#
|
||||
# Remove the comment character in front of the definition of
|
||||
# LDAPLIB that matches the name of the LDAP API library for the
|
||||
# version you've downloaded.
|
||||
#
|
||||
|
||||
|
||||
# For Win32 (NT)
|
||||
LDAPLIB=nsldap32v41
|
||||
#LDAPLIB=nsldapssl32v41
|
||||
NSPRLIB=libnspr3
|
||||
EXTRACFLAGS=-nologo -W3 -GT -GX -D_X86_ -Dx386 -DWIN32 -D_WINDOWS -c
|
||||
EXTRALDFLAGS=/NOLOGO /PDB:NONE /DEBUGTYPE:BOTH /SUBSYSTEM:console
|
||||
|
||||
|
||||
###############################################################################
|
||||
# You should not need to change anything below here....
|
||||
|
||||
INCDIR=../include
|
||||
LIBDIR=../lib
|
||||
NSPRINCDIR=../include
|
||||
NSPRLIBDIR=../lib
|
||||
|
||||
SYSLIBS=wsock32.lib kernel32.lib user32.lib shell32.lib
|
||||
LIBS=$(LIBDIR)/$(LDAPLIB).lib $(NSPRLIBDIR)/$(NSPRLIB).lib
|
||||
|
||||
CC=cl
|
||||
OPTFLAGS=-MD
|
||||
CFLAGS=$(OPTFLAGS) $(EXTRACFLAGS) -I$(INCDIR) -I$(NSPRINCDIR)
|
||||
LINK=link
|
||||
LDFLAGS=$(EXTRALDFLAGS)
|
||||
|
||||
|
||||
PROGS=search asearch csearch psearch rdentry getattrs srvrsort modattrs add del compare modrdn ppolicy getfilt crtfilt
|
||||
EXES=$(addsuffix .exe,$(PROGS))
|
||||
|
||||
SSLPROGS=ssnoauth ssearch
|
||||
SSLEXES=$(addsuffix .exe,$(SSLPROGS))
|
||||
|
||||
NSPRPROGS=nsprio
|
||||
NSPREXES=$(addsuffix .exe,$(NSPRPROGS))
|
||||
|
||||
ALLEXES= $(EXES) $(SSLEXES) $(NSEXES)
|
||||
|
||||
standard: $(EXES)
|
||||
|
||||
ssl: $(SSLEXES)
|
||||
|
||||
nspr: $(NSPREXES)
|
||||
|
||||
all: $(ALLEXES)
|
||||
|
||||
search.obj: examples.h
|
||||
|
||||
csearch.obj: examples.h
|
||||
|
||||
psearch.obj: examples.h
|
||||
|
||||
ssearch.obj: examples.h
|
||||
|
||||
ssnoauth.obj: examples.h
|
||||
|
||||
rdentry.obj: examples.h
|
||||
|
||||
getattrs.obj: examples.h
|
||||
|
||||
srvrsort.obj: examples.h
|
||||
|
||||
modattrs.obj: examples.h
|
||||
|
||||
asearch.obj: examples.h
|
||||
|
||||
add.obj: examples.h
|
||||
|
||||
del.obj: examples.h
|
||||
|
||||
compare.obj: examples.h
|
||||
|
||||
modrdn.obj: examples.h
|
||||
|
||||
ppolicy.obj: examples.h
|
||||
|
||||
getfilt.obj: examples.h
|
||||
|
||||
crtfilt.obj: examples.h
|
||||
|
||||
nsprio.obj: examples.h
|
||||
|
||||
runall: $(EXES)
|
||||
@for i in $(PROGS); do \
|
||||
echo '-------------------------------------------------'; \
|
||||
./$$i; \
|
||||
done
|
||||
|
||||
clean:
|
||||
rm -f $(ALLEXES) *.obj
|
||||
|
||||
%.obj : %.c
|
||||
$(CC) $(CFLAGS) $< -Fo$@
|
||||
|
||||
|
||||
%.exe : %.obj
|
||||
$(LINK) -OUT:$@ $(LDFLAGS) $(SYSLIBS) $< $(LIBS)
|
||||
@@ -0,0 +1,46 @@
|
||||
// ConnDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "winldap.h"
|
||||
#include "ConnDlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// ConnDlg dialog
|
||||
|
||||
|
||||
ConnDlg::ConnDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(ConnDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(ConnDlg)
|
||||
m_dirHost = _T("");
|
||||
m_dirPort = 0;
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void ConnDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(ConnDlg)
|
||||
DDX_Text(pDX, IDC_DIR_HOST, m_dirHost);
|
||||
DDX_Text(pDX, IDC_DIR_PORT, m_dirPort);
|
||||
DDV_MinMaxInt(pDX, m_dirPort, 1, 32000);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(ConnDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(ConnDlg)
|
||||
// NOTE: the ClassWizard will add message map macros here
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// ConnDlg message handlers
|
||||
@@ -0,0 +1,36 @@
|
||||
// ConnDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// ConnDlg dialog
|
||||
|
||||
class ConnDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
ConnDlg(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(ConnDlg)
|
||||
enum { IDD = IDD_CONNECT_DIALOG };
|
||||
CString m_dirHost;
|
||||
int m_dirPort;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(ConnDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(ConnDlg)
|
||||
// NOTE: the ClassWizard will add member functions here
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
NAME LDAP16
|
||||
EXETYPE WINDOWS
|
||||
CODE PRELOAD MOVEABLE DISCARDABLE
|
||||
DATA PRELOAD MOVEABLE MULTIPLE
|
||||
HEAPSIZE 1024
|
||||
|
||||
EXPORTS
|
||||
; ===List your explicitly exported functions here===
|
||||
186
mozilla/directory/c-sdk/ldap/examples/windows/winldap/LDAP16.MAK
Normal file
186
mozilla/directory/c-sdk/ldap/examples/windows/winldap/LDAP16.MAK
Normal file
@@ -0,0 +1,186 @@
|
||||
# Microsoft Visual C++ generated build script - Do not modify
|
||||
|
||||
PROJ = LDAP16
|
||||
DEBUG = 0
|
||||
PROGTYPE = 0
|
||||
CALLER =
|
||||
ARGS =
|
||||
DLLS =
|
||||
D_RCDEFINES = -d_DEBUG
|
||||
R_RCDEFINES = -dNDEBUG
|
||||
ORIGIN = MSVC
|
||||
ORIGIN_VER = 1.00
|
||||
PROJPATH = C:\NETSCAPE\LDAPSDK\EXAMPLES\WINDOWS\WINLDAP\
|
||||
USEMFC = 1
|
||||
CC = cl
|
||||
CPP = cl
|
||||
CXX = cl
|
||||
CCREATEPCHFLAG =
|
||||
CPPCREATEPCHFLAG =
|
||||
CUSEPCHFLAG =
|
||||
CPPUSEPCHFLAG =
|
||||
FIRSTC =
|
||||
FIRSTCPP = CONNDLG.CPP
|
||||
RC = rc
|
||||
CFLAGS_D_WEXE = /nologo /G3 /W3 /Zi /AL /Od /D "_DEBUG" /D "_AFX_NO_AFXCMN_SUPPORT" /D "_WINDOWS" /FR /GA /Fd"LDAP16.PDB"
|
||||
CFLAGS_R_WEXE = /nologo /W3 /AL /O1 /D "NDEBUG" /D "_AFX_NO_AFXCMN_SUPPORT" /D "_WINDOWS" /FR /GA
|
||||
LFLAGS_D_WEXE = /NOLOGO /NOD /PACKC:61440 /STACK:10240 /ALIGN:16 /ONERROR:NOEXE /CO
|
||||
LFLAGS_R_WEXE = /NOLOGO /NOD /PACKC:61440 /STACK:10240 /ALIGN:16 /ONERROR:NOEXE
|
||||
LIBS_D_WEXE = nsldap.lib lafxcwd oldnames libw llibcew commdlg.lib shell.lib
|
||||
LIBS_R_WEXE = nsldap.lib lafxcw oldnames libw llibcew commdlg.lib shell.lib
|
||||
RCFLAGS = /nologo
|
||||
RESFLAGS = /nologo
|
||||
RUNFLAGS =
|
||||
DEFFILE = LDAP16.DEF
|
||||
OBJS_EXT =
|
||||
LIBS_EXT =
|
||||
!if "$(DEBUG)" == "1"
|
||||
CFLAGS = $(CFLAGS_D_WEXE)
|
||||
LFLAGS = $(LFLAGS_D_WEXE)
|
||||
LIBS = $(LIBS_D_WEXE)
|
||||
MAPFILE = nul
|
||||
RCDEFINES = $(D_RCDEFINES)
|
||||
!else
|
||||
CFLAGS = $(CFLAGS_R_WEXE)
|
||||
LFLAGS = $(LFLAGS_R_WEXE)
|
||||
LIBS = $(LIBS_R_WEXE)
|
||||
MAPFILE = nul
|
||||
RCDEFINES = $(R_RCDEFINES)
|
||||
!endif
|
||||
!if [if exist MSVC.BND del MSVC.BND]
|
||||
!endif
|
||||
SBRS = CONNDLG.SBR \
|
||||
LDAPDOC.SBR \
|
||||
LDAPVIEW.SBR \
|
||||
MAINFRM.SBR \
|
||||
PROPDLG.SBR \
|
||||
SRCHDLG.SBR \
|
||||
STDAFX.SBR \
|
||||
WINLDAP.SBR
|
||||
|
||||
|
||||
CONNDLG_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h \
|
||||
c:\netscape\ldapsdk\examples\windows\winldap\winldap.h \
|
||||
c:\netscape\ldapsdk\examples\windows\winldap\conndlg.h
|
||||
|
||||
|
||||
LDAPDOC_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h \
|
||||
c:\netscape\ldapsdk\examples\windows\winldap\winldap.h \
|
||||
c:\netscape\ldapsdk\examples\windows\winldap\ldapdoc.h
|
||||
|
||||
|
||||
LDAPVIEW_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h \
|
||||
c:\netscape\ldapsdk\include\ldap.h \
|
||||
c:\netscape\ldapsdk\include\lber.h \
|
||||
c:\netscape\ldapsdk\examples\windows\winldap\winldap.h \
|
||||
c:\netscape\ldapsdk\examples\windows\winldap\ldapdoc.h \
|
||||
c:\netscape\ldapsdk\examples\windows\winldap\ldapview.h \
|
||||
c:\netscape\ldapsdk\examples\windows\winldap\propdlg.h
|
||||
|
||||
|
||||
MAINFRM_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h \
|
||||
c:\netscape\ldapsdk\include\ldap.h \
|
||||
c:\netscape\ldapsdk\include\lber.h \
|
||||
c:\netscape\ldapsdk\examples\windows\winldap\winldap.h \
|
||||
c:\netscape\ldapsdk\examples\windows\winldap\mainfrm.h
|
||||
|
||||
|
||||
PROPDLG_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h \
|
||||
c:\netscape\ldapsdk\include\ldap.h \
|
||||
c:\netscape\ldapsdk\include\lber.h \
|
||||
c:\netscape\ldapsdk\examples\windows\winldap\winldap.h \
|
||||
c:\netscape\ldapsdk\examples\windows\winldap\propdlg.h
|
||||
|
||||
|
||||
SRCHDLG_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h \
|
||||
c:\netscape\ldapsdk\include\ldap.h \
|
||||
c:\netscape\ldapsdk\include\lber.h \
|
||||
c:\netscape\ldapsdk\examples\windows\winldap\winldap.h \
|
||||
c:\netscape\ldapsdk\examples\windows\winldap\srchdlg.h
|
||||
|
||||
|
||||
STDAFX_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h
|
||||
|
||||
|
||||
WINLDAP_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h \
|
||||
c:\netscape\ldapsdk\include\ldap.h \
|
||||
c:\netscape\ldapsdk\include\lber.h \
|
||||
c:\netscape\ldapsdk\examples\windows\winldap\winldap.h \
|
||||
c:\netscape\ldapsdk\examples\windows\winldap\mainfrm.h \
|
||||
c:\netscape\ldapsdk\examples\windows\winldap\ldapdoc.h \
|
||||
c:\netscape\ldapsdk\examples\windows\winldap\ldapview.h \
|
||||
c:\netscape\ldapsdk\examples\windows\winldap\conndlg.h \
|
||||
c:\netscape\ldapsdk\examples\windows\winldap\srchdlg.h
|
||||
|
||||
|
||||
LDAP16_RCDEP = c:\netscape\ldapsdk\examples\windows\winldap\res\winldap.ico \
|
||||
c:\netscape\ldapsdk\examples\windows\winldap\res\winldap.rc2
|
||||
|
||||
|
||||
all: $(PROJ).EXE $(PROJ).BSC
|
||||
|
||||
CONNDLG.OBJ: CONNDLG.CPP $(CONNDLG_DEP)
|
||||
$(CPP) $(CFLAGS) $(CPPCREATEPCHFLAG) /c CONNDLG.CPP
|
||||
|
||||
LDAPDOC.OBJ: LDAPDOC.CPP $(LDAPDOC_DEP)
|
||||
$(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c LDAPDOC.CPP
|
||||
|
||||
LDAPVIEW.OBJ: LDAPVIEW.CPP $(LDAPVIEW_DEP)
|
||||
$(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c LDAPVIEW.CPP
|
||||
|
||||
MAINFRM.OBJ: MAINFRM.CPP $(MAINFRM_DEP)
|
||||
$(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c MAINFRM.CPP
|
||||
|
||||
PROPDLG.OBJ: PROPDLG.CPP $(PROPDLG_DEP)
|
||||
$(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c PROPDLG.CPP
|
||||
|
||||
SRCHDLG.OBJ: SRCHDLG.CPP $(SRCHDLG_DEP)
|
||||
$(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c SRCHDLG.CPP
|
||||
|
||||
STDAFX.OBJ: STDAFX.CPP $(STDAFX_DEP)
|
||||
$(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c STDAFX.CPP
|
||||
|
||||
WINLDAP.OBJ: WINLDAP.CPP $(WINLDAP_DEP)
|
||||
$(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c WINLDAP.CPP
|
||||
|
||||
LDAP16.RES: LDAP16.RC $(LDAP16_RCDEP)
|
||||
$(RC) $(RCFLAGS) $(RCDEFINES) -r LDAP16.RC
|
||||
|
||||
|
||||
$(PROJ).EXE:: LDAP16.RES
|
||||
|
||||
$(PROJ).EXE:: CONNDLG.OBJ LDAPDOC.OBJ LDAPVIEW.OBJ MAINFRM.OBJ PROPDLG.OBJ SRCHDLG.OBJ \
|
||||
STDAFX.OBJ WINLDAP.OBJ $(OBJS_EXT) $(DEFFILE)
|
||||
echo >NUL @<<$(PROJ).CRF
|
||||
STDAFX.OBJ +
|
||||
CONNDLG.OBJ +
|
||||
LDAPDOC.OBJ +
|
||||
LDAPVIEW.OBJ +
|
||||
MAINFRM.OBJ +
|
||||
PROPDLG.OBJ +
|
||||
SRCHDLG.OBJ +
|
||||
WINLDAP.OBJ +
|
||||
$(OBJS_EXT)
|
||||
$(PROJ).EXE
|
||||
$(MAPFILE)
|
||||
C:\MSVC\LIB\+
|
||||
C:\MSVC\MFC\LIB\+
|
||||
..\..\..\lib\+
|
||||
$(LIBS)
|
||||
$(DEFFILE);
|
||||
<<
|
||||
link $(LFLAGS) @$(PROJ).CRF
|
||||
$(RC) $(RESFLAGS) LDAP16.RES $@
|
||||
@copy $(PROJ).CRF MSVC.BND
|
||||
|
||||
$(PROJ).EXE:: LDAP16.RES
|
||||
if not exist MSVC.BND $(RC) $(RESFLAGS) LDAP16.RES $@
|
||||
|
||||
run: $(PROJ).EXE
|
||||
$(PROJ) $(RUNFLAGS)
|
||||
|
||||
|
||||
$(PROJ).BSC: $(SBRS)
|
||||
bscmake @<<
|
||||
/o$@ $(SBRS)
|
||||
<<
|
||||
241
mozilla/directory/c-sdk/ldap/examples/windows/winldap/LDAP16.RC
Normal file
241
mozilla/directory/c-sdk/ldap/examples/windows/winldap/LDAP16.RC
Normal file
@@ -0,0 +1,241 @@
|
||||
//Microsoft App Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// From TEXTINCLUDE 2
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""res\\winldap.rc2"" // non-App Studio edited resources\r\n"
|
||||
"\r\n"
|
||||
"#include ""afxres.rc"" // Standard components\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
IDR_MAINFRAME ICON DISCARDABLE res\winldap.ico
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
IDR_MAINFRAME MENU PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&Connect...\tCtrl+N", ID_FILE_CONNECT
|
||||
MENUITEM "&Disconnect\tCtrl+D", ID_FILE_DISCONNECT
|
||||
MENUITEM "&Search...\tCtrl+S", ID_FILE_SEARCH
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", ID_APP_EXIT
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&About Test16...", ID_APP_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE
|
||||
BEGIN
|
||||
"N", ID_FILE_NEW, VIRTKEY,CONTROL
|
||||
"O", ID_FILE_OPEN, VIRTKEY,CONTROL
|
||||
"S", ID_FILE_SAVE, VIRTKEY,CONTROL
|
||||
"Z", ID_EDIT_UNDO, VIRTKEY,CONTROL
|
||||
"X", ID_EDIT_CUT, VIRTKEY,CONTROL
|
||||
"C", ID_EDIT_COPY, VIRTKEY,CONTROL
|
||||
"V", ID_EDIT_PASTE, VIRTKEY,CONTROL
|
||||
VK_BACK, ID_EDIT_UNDO, VIRTKEY,ALT
|
||||
VK_DELETE, ID_EDIT_CUT, VIRTKEY,SHIFT
|
||||
VK_INSERT, ID_EDIT_COPY, VIRTKEY,CONTROL
|
||||
VK_INSERT, ID_EDIT_PASTE, VIRTKEY,SHIFT
|
||||
VK_F6, ID_NEXT_PANE, VIRTKEY
|
||||
VK_F6, ID_PREV_PANE, VIRTKEY,SHIFT
|
||||
END
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_ABOUTBOX DIALOG DISCARDABLE 34, 22, 217, 55
|
||||
CAPTION "About Test16"
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20
|
||||
LTEXT "Test16 Application Version 1.0",IDC_STATIC,40,10,119,8
|
||||
LTEXT "Copyright \251 1997",IDC_STATIC,40,25,119,8
|
||||
DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP
|
||||
END
|
||||
|
||||
IDD_CONNECT_DIALOG DIALOG DISCARDABLE 0, 0, 186, 76
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Connect to Directory Server"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,35,55,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,103,55,50,14
|
||||
RTEXT "Host name:",IDC_STATIC,21,17,52,12
|
||||
EDITTEXT IDC_DIR_PORT,79,33,92,14,ES_AUTOHSCROLL
|
||||
RTEXT "Port number:",IDC_STATIC,28,36,45,12
|
||||
EDITTEXT IDC_DIR_HOST,79,14,92,14,ES_AUTOHSCROLL
|
||||
END
|
||||
|
||||
IDD_SEARCH_DIALOG DIALOG DISCARDABLE 0, 0, 186, 103
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Search parameters"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,39,82,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,105,82,50,14
|
||||
RTEXT "Directory base:",IDC_STATIC,7,16,54,12
|
||||
EDITTEXT IDC_SEARCH_BASE,65,13,106,14,ES_AUTOHSCROLL
|
||||
RTEXT "Search filter:",IDC_STATIC,10,34,51,12
|
||||
EDITTEXT IDC_SEARCH_FILTER,65,31,105,14,ES_AUTOHSCROLL
|
||||
CONTROL "Base",IDC_SCOPE_BASE,"Button",BS_AUTORADIOBUTTON,23,60,
|
||||
32,10
|
||||
CONTROL "One level",IDC_SCOPE_ONE,"Button",BS_AUTORADIOBUTTON,69,
|
||||
60,46,10
|
||||
CONTROL "Subtree",IDC_SCOPE_SUB,"Button",BS_AUTORADIOBUTTON,121,
|
||||
60,41,10
|
||||
GROUPBOX "Scope",IDC_STATIC,13,49,159,24
|
||||
END
|
||||
|
||||
IDD_ENTRY_PROPERTIES DIALOG DISCARDABLE 0, 0, 273, 202
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Properties"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
END
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
IDR_MAINFRAME "winldap\n\nWinlda\n\n\nWinldap.Document\nWinlda Document"
|
||||
END
|
||||
STRINGTABLE PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_APP_TITLE "Test16 Windows Application"
|
||||
AFX_IDS_IDLEMESSAGE "Ready"
|
||||
END
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_INDICATOR_EXT "EXT"
|
||||
ID_INDICATOR_CAPS "CAP"
|
||||
ID_INDICATOR_NUM "NUM"
|
||||
ID_INDICATOR_SCRL "SCRL"
|
||||
ID_INDICATOR_OVR "OVR"
|
||||
ID_INDICATOR_REC "REC"
|
||||
END
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_FILE_NEW "Create a new document"
|
||||
ID_FILE_OPEN "Open an existing document"
|
||||
ID_FILE_CLOSE "Close the active document"
|
||||
ID_FILE_SAVE "Save the active document"
|
||||
ID_FILE_SAVE_AS "Save the active document with a new name"
|
||||
ID_APP_ABOUT "Display program information, version number and copyright"
|
||||
ID_APP_EXIT "Quit the application; prompts to save documents"
|
||||
ID_FILE_MRU_FILE1 "Open this document"
|
||||
ID_FILE_MRU_FILE2 "Open this document"
|
||||
ID_FILE_MRU_FILE3 "Open this document"
|
||||
ID_FILE_MRU_FILE4 "Open this document"
|
||||
ID_NEXT_PANE "Switch to the next window pane"
|
||||
ID_PREV_PANE "Switch back to the previous window pane"
|
||||
ID_EDIT_CLEAR "Erase the selection"
|
||||
ID_EDIT_CLEAR_ALL "Erase everything"
|
||||
ID_EDIT_COPY "Copy the selection and put it on the Clipboard"
|
||||
ID_EDIT_CUT "Cut the selection and put it on the Clipboard"
|
||||
ID_EDIT_FIND "Find the specified text"
|
||||
ID_EDIT_PASTE "Insert Clipboard contents"
|
||||
ID_EDIT_REPEAT "Repeat the last action"
|
||||
ID_EDIT_REPLACE "Replace specific text with different text"
|
||||
ID_EDIT_SELECT_ALL "Select the entire document"
|
||||
ID_EDIT_UNDO "Undo the last action"
|
||||
ID_EDIT_REDO "Redo the previously undone action"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_SCSIZE "Change the window size"
|
||||
AFX_IDS_SCMOVE "Change the window position"
|
||||
AFX_IDS_SCMINIMIZE "Reduce the window to an icon"
|
||||
AFX_IDS_SCMAXIMIZE "Enlarge the window to full size"
|
||||
AFX_IDS_SCNEXTWINDOW "Switch to the next document window"
|
||||
AFX_IDS_SCPREVWINDOW "Switch to the previous document window"
|
||||
AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents"
|
||||
AFX_IDS_SCRESTORE "Restore the window to normal size"
|
||||
AFX_IDS_SCTASKLIST "Activate Task List"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_FILE_CONNECT "Connect to Directory Server"
|
||||
ID_FILE_DISCONNECT "Disconnect from Directory Server"
|
||||
ID_FILE_SEARCH "Search in Directory"
|
||||
END
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// From TEXTINCLUDE 3
|
||||
//
|
||||
|
||||
#include "res\winldap.rc2" // non-App Studio edited resources
|
||||
|
||||
#include "afxres.rc" // Standard components
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
@@ -0,0 +1,76 @@
|
||||
// LdapDoc.cpp : implementation of the LdapDoc class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "winldap.h"
|
||||
|
||||
#include "LdapDoc.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#ifdef _WIN32
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// LdapDoc
|
||||
|
||||
IMPLEMENT_DYNCREATE(LdapDoc, CDocument)
|
||||
|
||||
BEGIN_MESSAGE_MAP(LdapDoc, CDocument)
|
||||
//{{AFX_MSG_MAP(LdapDoc)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// LdapDoc construction/destruction
|
||||
|
||||
LdapDoc::LdapDoc()
|
||||
{
|
||||
}
|
||||
|
||||
LdapDoc::~LdapDoc()
|
||||
{
|
||||
}
|
||||
|
||||
BOOL LdapDoc::OnNewDocument()
|
||||
{
|
||||
if (!CDocument::OnNewDocument())
|
||||
return FALSE;
|
||||
|
||||
SetTitle( "" );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// LdapDoc serialization
|
||||
|
||||
void LdapDoc::Serialize(CArchive& ar)
|
||||
{
|
||||
if (ar.IsStoring())
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// LdapDoc diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void LdapDoc::AssertValid() const
|
||||
{
|
||||
CDocument::AssertValid();
|
||||
}
|
||||
|
||||
void LdapDoc::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CDocument::Dump(dc);
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// LdapDoc commands
|
||||
@@ -0,0 +1,42 @@
|
||||
// LdapDoc.h : interface of the LdapDoc class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class LdapDoc : public CDocument
|
||||
{
|
||||
protected: // create from serialization only
|
||||
LdapDoc();
|
||||
DECLARE_DYNCREATE(LdapDoc)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(LdapDoc)
|
||||
public:
|
||||
virtual BOOL OnNewDocument();
|
||||
virtual void Serialize(CArchive& ar);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~LdapDoc();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(LdapDoc)
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,190 @@
|
||||
// LdapView.cpp : implementation of the LdapView class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "ldap.h"
|
||||
#include "winldap.h"
|
||||
|
||||
#include "LdapDoc.h"
|
||||
#include "LdapView.h"
|
||||
#include "PropDlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#ifdef _WIN32
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// LdapView
|
||||
|
||||
IMPLEMENT_DYNCREATE(LdapView, CView)
|
||||
|
||||
BEGIN_MESSAGE_MAP(LdapView, CView)
|
||||
//{{AFX_MSG_MAP(LdapView)
|
||||
ON_WM_SIZE()
|
||||
ON_LBN_DBLCLK(5000,OnListDoubleClick)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// LdapView construction/destruction
|
||||
|
||||
LdapView::LdapView()
|
||||
{
|
||||
}
|
||||
|
||||
LdapView::~LdapView()
|
||||
{
|
||||
}
|
||||
|
||||
BOOL LdapView::PreCreateWindow(CREATESTRUCT& cs)
|
||||
{
|
||||
return CView::PreCreateWindow(cs);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// LdapView drawing
|
||||
|
||||
void LdapView::OnDraw(CDC* pDC)
|
||||
{
|
||||
LdapDoc* pDoc = GetDocument();
|
||||
ASSERT_VALID(pDoc);
|
||||
}
|
||||
|
||||
void LdapView::OnInitialUpdate()
|
||||
{
|
||||
CView::OnInitialUpdate();
|
||||
// Create a list box the same size as the client area
|
||||
CRect rect;
|
||||
GetClientRect( &rect );
|
||||
m_list.Create( WS_CHILD|WS_VISIBLE|WS_VSCROLL|LBS_NOTIFY, rect, this, 5000 );
|
||||
}
|
||||
|
||||
void LdapView::AddLine( LPCSTR line, const char *dn )
|
||||
{
|
||||
// Add a string to the list box
|
||||
int ind = m_list.AddString( line );
|
||||
if ( NULL != dn )
|
||||
m_list.SetItemDataPtr( ind, (void *)strdup(dn) );
|
||||
}
|
||||
|
||||
void LdapView::ClearLines()
|
||||
{
|
||||
// Remove all lines from the list box
|
||||
int nCount = m_list.GetCount();
|
||||
while ( nCount > 0 )
|
||||
{
|
||||
char *str = (char *)m_list.GetItemDataPtr( 0 );
|
||||
if ( str )
|
||||
free( str );
|
||||
nCount = m_list.DeleteString( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// LdapView diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void LdapView::AssertValid() const
|
||||
{
|
||||
CView::AssertValid();
|
||||
}
|
||||
|
||||
void LdapView::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CView::Dump(dc);
|
||||
}
|
||||
|
||||
LdapDoc* LdapView::GetDocument() // non-debug version is inline
|
||||
{
|
||||
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(LdapDoc)));
|
||||
return (LdapDoc*)m_pDocument;
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// LdapView message handlers
|
||||
|
||||
void LdapView::OnSize(UINT nType, int cx, int cy)
|
||||
{
|
||||
// Make sure the list box is resized along with the View
|
||||
CView::OnSize(nType, cx, cy);
|
||||
if ( ::IsWindow( m_list.m_hWnd ) )
|
||||
m_list.SetWindowPos( &wndTop, 0, 0, cx, cy, SWP_NOZORDER );
|
||||
}
|
||||
|
||||
// Fetch all attributes of an entry, and display them in a dialog
|
||||
void LdapView::showProperties( LDAP *ld, char *dn )
|
||||
{
|
||||
PropDlg dlg;
|
||||
if ( ldap_search( ld, dn, LDAP_SCOPE_BASE, "objectclass=*",
|
||||
NULL, FALSE ) == -1 )
|
||||
{
|
||||
AfxMessageBox( "Failed to start asynchronous search" );
|
||||
return;
|
||||
}
|
||||
|
||||
LDAPMessage *res;
|
||||
int rc;
|
||||
// Process results as they come in
|
||||
while ( (rc = ldap_result( ld, LDAP_RES_ANY, 0, NULL, &res ))
|
||||
== LDAP_RES_SEARCH_ENTRY )
|
||||
{
|
||||
LDAPMessage *e = ldap_first_entry( ld, res );
|
||||
BerElement *ber;
|
||||
// Loop over attributes in this entry
|
||||
for ( char *a = ldap_first_attribute( ld, e, &ber ); a != NULL;
|
||||
a = ldap_next_attribute( ld, e, ber ) )
|
||||
{
|
||||
struct berval **bvals;
|
||||
if ( (bvals = ldap_get_values_len( ld, e, a )) != NULL )
|
||||
{
|
||||
dlg.AddLine( a );
|
||||
// Loop over values for this attribute
|
||||
for ( int i = 0; bvals[i] != NULL; i++ )
|
||||
{
|
||||
CString val;
|
||||
val.Format( " %s", bvals[ i ]->bv_val );
|
||||
dlg.AddLine( val );
|
||||
}
|
||||
ber_bvecfree( bvals );
|
||||
}
|
||||
}
|
||||
if ( ber != NULL )
|
||||
ber_free( ber, 0 );
|
||||
ldap_msgfree( res );
|
||||
}
|
||||
if ( rc == -1 )
|
||||
{
|
||||
AfxMessageBox( "Error on ldap_result" );
|
||||
return;
|
||||
}
|
||||
else if (( rc = ldap_result2error( ld, res, 0 )) != LDAP_SUCCESS )
|
||||
{
|
||||
char *errString = ldap_err2string( rc );
|
||||
AfxMessageBox( errString );
|
||||
}
|
||||
ldap_msgfree( res );
|
||||
// Set the title of the dialog to the distinguished name, and display it
|
||||
dlg.SetTitle( dn );
|
||||
dlg.DoModal();
|
||||
}
|
||||
|
||||
// Catch double-clicks on the list box, and fetch properties for a dn
|
||||
void LdapView::OnListDoubleClick()
|
||||
{
|
||||
int ind = m_list.GetCurSel();
|
||||
if ( ind >= 0 )
|
||||
{
|
||||
char *dn = (char *)m_list.GetItemDataPtr( ind );
|
||||
if ( NULL != dn )
|
||||
{
|
||||
LDAP *ld = ((LdapApp *)AfxGetApp())->GetConnection();
|
||||
if ( NULL != ld )
|
||||
showProperties( ld, dn );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
// LdapView.h : interface of the LdapView class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class LdapView : public CView
|
||||
{
|
||||
protected: // create from serialization only
|
||||
LdapView();
|
||||
DECLARE_DYNCREATE(LdapView)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
LdapDoc* GetDocument();
|
||||
|
||||
private:
|
||||
CListBox m_list;
|
||||
|
||||
// Operations
|
||||
public:
|
||||
void AddLine( LPCSTR line, const char *dn=NULL );
|
||||
void ClearLines();
|
||||
|
||||
private:
|
||||
void showProperties( LDAP *ld, char *dn );
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(LdapView)
|
||||
public:
|
||||
virtual void OnDraw(CDC* pDC); // overridden to draw this view
|
||||
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
|
||||
protected:
|
||||
virtual void OnInitialUpdate(); // called first time after construct
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~LdapView();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(LdapView)
|
||||
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||
afx_msg void OnListDoubleClick();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
#ifndef _DEBUG // debug version in LdapView.cpp
|
||||
inline LdapDoc* LdapView::GetDocument()
|
||||
{ return (LdapDoc*)m_pDocument; }
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,85 @@
|
||||
// MainFrm.cpp : implementation of the CMainFrame class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "winldap.h"
|
||||
|
||||
#include "MainFrm.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#ifdef _WIN32
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame
|
||||
|
||||
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
|
||||
//{{AFX_MSG_MAP(CMainFrame)
|
||||
ON_WM_CREATE()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
static UINT indicators[] =
|
||||
{
|
||||
ID_SEPARATOR, // status line indicator
|
||||
ID_INDICATOR_CAPS,
|
||||
ID_INDICATOR_NUM,
|
||||
ID_INDICATOR_SCRL,
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame construction/destruction
|
||||
|
||||
CMainFrame::CMainFrame()
|
||||
{
|
||||
}
|
||||
|
||||
CMainFrame::~CMainFrame()
|
||||
{
|
||||
}
|
||||
|
||||
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
||||
{
|
||||
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
|
||||
return -1;
|
||||
|
||||
if (!m_wndStatusBar.Create(this) ||
|
||||
!m_wndStatusBar.SetIndicators(indicators,
|
||||
sizeof(indicators)/sizeof(UINT)))
|
||||
{
|
||||
TRACE0("Failed to create status bar\n");
|
||||
return -1; // fail to create
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
|
||||
{
|
||||
return CFrameWnd::PreCreateWindow(cs);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CMainFrame::AssertValid() const
|
||||
{
|
||||
CFrameWnd::AssertValid();
|
||||
}
|
||||
|
||||
void CMainFrame::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CFrameWnd::Dump(dc);
|
||||
}
|
||||
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame message handlers
|
||||
@@ -0,0 +1,43 @@
|
||||
// MainFrm.h : interface of the CMainFrame class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CMainFrame : public CFrameWnd
|
||||
{
|
||||
protected: // create from serialization only
|
||||
CMainFrame();
|
||||
DECLARE_DYNCREATE(CMainFrame)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CMainFrame)
|
||||
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CMainFrame();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected: // control bar embedded members
|
||||
CStatusBar m_wndStatusBar;
|
||||
CToolBar m_wndToolBar;
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CMainFrame)
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,78 @@
|
||||
// PropDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "winldap.h"
|
||||
#include "PropDlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#ifdef _WIN32
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// PropDlg dialog
|
||||
|
||||
|
||||
PropDlg::PropDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(PropDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(PropDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void PropDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(PropDlg)
|
||||
// NOTE: the ClassWizard will add DDX and DDV calls here
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(PropDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(PropDlg)
|
||||
ON_WM_SIZE()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// PropDlg message handlers
|
||||
|
||||
void PropDlg::OnSize(UINT nType, int cx, int cy)
|
||||
{
|
||||
CDialog::OnSize(nType, cx, cy);
|
||||
|
||||
if ( ::IsWindow( m_list.m_hWnd ) )
|
||||
m_list.SetWindowPos( &wndTop, 0, 0, cx, cy, SWP_NOZORDER );
|
||||
}
|
||||
|
||||
BOOL PropDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
if ( m_title.GetLength() > 0 )
|
||||
SetWindowText( m_title );
|
||||
CRect rect;
|
||||
GetClientRect( &rect );
|
||||
m_list.Create( WS_CHILD|WS_VISIBLE|WS_VSCROLL|LBS_NOTIFY, rect, this, 5000 );
|
||||
|
||||
POSITION pos;
|
||||
// Iterate through the list in head-to-tail order.
|
||||
for( pos = m_strings.GetHeadPosition(); pos != NULL; )
|
||||
{
|
||||
m_list.AddString( m_strings.GetNext( pos ) );
|
||||
}
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void PropDlg::AddLine( const char *str )
|
||||
{
|
||||
m_strings.AddTail( str );
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// PropDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// PropDlg dialog
|
||||
|
||||
class PropDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
PropDlg(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(PropDlg)
|
||||
enum { IDD = IDD_ENTRY_PROPERTIES };
|
||||
// NOTE: the ClassWizard will add data members here
|
||||
//}}AFX_DATA
|
||||
|
||||
void SetTitle( const char *str ) { m_title = str; }
|
||||
|
||||
private:
|
||||
CListBox m_list;
|
||||
CStringList m_strings;
|
||||
CString m_title;
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(PropDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
void AddLine( const char *line );
|
||||
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(PropDlg)
|
||||
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||
virtual BOOL OnInitDialog();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by winldap.rc
|
||||
//
|
||||
#define IDD_ABOUTBOX 100
|
||||
#define IDR_MAINFRAME 128
|
||||
#define IDR_WINLDATYPE 129
|
||||
#define IDD_CONNECT_DIALOG 130
|
||||
#define IDD_SEARCH_DIALOG 131
|
||||
#define IDD_ENTRY_PROPERTIES 132
|
||||
#define IDC_SEARCH_BASE 1000
|
||||
#define IDC_DIR_PORT 1001
|
||||
#define IDC_SEARCH_FILTER 1001
|
||||
#define IDC_DIR_HOST 1002
|
||||
#define IDC_SCOPE_BASE 1002
|
||||
#define IDC_SCOPE_ONE 1003
|
||||
#define IDC_SCOPE_SUB 1004
|
||||
#define ID_FILE_CONNECT 32771
|
||||
#define ID_FILE_DISCONNECT 32772
|
||||
#define ID_FILE_SEARCH 32773
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_3D_CONTROLS 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 133
|
||||
#define _APS_NEXT_COMMAND_VALUE 32774
|
||||
#define _APS_NEXT_CONTROL_VALUE 1003
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,89 @@
|
||||
// SrchDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "ldap.h"
|
||||
#include "winldap.h"
|
||||
#include "SrchDlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#ifdef _WIN32
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// SearchDlg dialog
|
||||
|
||||
|
||||
SearchDlg::SearchDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(SearchDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(SearchDlg)
|
||||
m_searchBase = _T("");
|
||||
m_searchFilter = _T("");
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void SearchDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(SearchDlg)
|
||||
DDX_Text(pDX, IDC_SEARCH_BASE, m_searchBase);
|
||||
DDX_Text(pDX, IDC_SEARCH_FILTER, m_searchFilter);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(SearchDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(SearchDlg)
|
||||
ON_BN_CLICKED(IDC_SCOPE_BASE, OnScopeBase)
|
||||
ON_BN_DOUBLECLICKED(IDC_SCOPE_BASE, OnScopeBase)
|
||||
ON_BN_CLICKED(IDC_SCOPE_ONE, OnScopeOne)
|
||||
ON_BN_DOUBLECLICKED(IDC_SCOPE_ONE, OnScopeOne)
|
||||
ON_BN_CLICKED(IDC_SCOPE_SUB, OnScopeSub)
|
||||
ON_BN_DOUBLECLICKED(IDC_SCOPE_SUB, OnScopeSub)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// SearchDlg message handlers
|
||||
|
||||
BOOL SearchDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
switch( m_scope )
|
||||
{
|
||||
case LDAP_SCOPE_SUBTREE:
|
||||
((CButton *)GetDlgItem( IDC_SCOPE_SUB ))->SetCheck( 1 );
|
||||
break;
|
||||
case LDAP_SCOPE_BASE:
|
||||
((CButton *)GetDlgItem( IDC_SCOPE_BASE ))->SetCheck( 1 );
|
||||
break;
|
||||
case LDAP_SCOPE_ONELEVEL:
|
||||
((CButton *)GetDlgItem( IDC_SCOPE_ONE ))->SetCheck( 1 );
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void SearchDlg::OnScopeBase()
|
||||
{
|
||||
m_scope = LDAP_SCOPE_BASE;
|
||||
}
|
||||
|
||||
void SearchDlg::OnScopeOne()
|
||||
{
|
||||
m_scope = LDAP_SCOPE_ONELEVEL;
|
||||
}
|
||||
|
||||
void SearchDlg::OnScopeSub()
|
||||
{
|
||||
m_scope = LDAP_SCOPE_SUBTREE;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// SrchDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// SearchDlg dialog
|
||||
|
||||
class SearchDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
SearchDlg(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
public:
|
||||
void SetScope( int scope ) { m_scope = scope; }
|
||||
int GetScope() { return m_scope; }
|
||||
|
||||
private:
|
||||
int m_scope;
|
||||
|
||||
public:
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(SearchDlg)
|
||||
enum { IDD = IDD_SEARCH_DIALOG };
|
||||
CString m_searchBase;
|
||||
CString m_searchFilter;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(SearchDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(SearchDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnScopeBase();
|
||||
afx_msg void OnScopeOne();
|
||||
afx_msg void OnScopeSub();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// winldap.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include <afxwin.h> // MFC core and standard components
|
||||
#include <afxext.h> // MFC extensions
|
||||
#ifdef _WIN32
|
||||
#include <afxcview.h>
|
||||
#ifndef _AFX_NO_AFXCMN_SUPPORT
|
||||
#include <afxcmn.h> // MFC support for Windows Common Controls
|
||||
#endif // _AFX_NO_AFXCMN_SUPPORT
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// WINLDAP.RC2 - resources Microsoft Visual C++ does not edit directly
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#error this file is not editable by Microsoft Visual C++
|
||||
#endif //APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Add manually edited resources here...
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,298 @@
|
||||
// winldap.cpp : Defines the class behaviors for the application.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "ldap.h"
|
||||
#include "winldap.h"
|
||||
|
||||
#include "MainFrm.h"
|
||||
#include "LdapDoc.h"
|
||||
#include "LdapView.h"
|
||||
#include "ConnDlg.h"
|
||||
#include "SrchDlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#ifdef _WIN32
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// LdapApp
|
||||
|
||||
BEGIN_MESSAGE_MAP(LdapApp, CWinApp)
|
||||
//{{AFX_MSG_MAP(LdapApp)
|
||||
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
|
||||
ON_COMMAND(ID_FILE_CONNECT, OnFileConnect)
|
||||
ON_UPDATE_COMMAND_UI(ID_FILE_CONNECT, OnUpdateFileConnect)
|
||||
ON_COMMAND(ID_FILE_DISCONNECT, OnFileDisconnect)
|
||||
ON_UPDATE_COMMAND_UI(ID_FILE_DISCONNECT, OnUpdateFileDisconnect)
|
||||
ON_COMMAND(ID_FILE_SEARCH, OnFileSearch)
|
||||
ON_UPDATE_COMMAND_UI(ID_FILE_SEARCH, OnUpdateFileSearch)
|
||||
//}}AFX_MSG_MAP
|
||||
// Standard file based document commands
|
||||
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
|
||||
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// LdapApp construction
|
||||
|
||||
LdapApp::LdapApp()
|
||||
{
|
||||
m_ld = NULL;
|
||||
m_connected = FALSE;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// The one and only LdapApp object
|
||||
|
||||
LdapApp theApp;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// LdapApp initialization
|
||||
|
||||
BOOL LdapApp::InitInstance()
|
||||
{
|
||||
// Standard initialization
|
||||
#ifdef _WIN32
|
||||
#ifdef _AFXDLL
|
||||
Enable3dControls(); // Call this when using MFC in a shared DLL
|
||||
#else
|
||||
Enable3dControlsStatic(); // Call this when linking to MFC statically
|
||||
#endif
|
||||
#endif
|
||||
|
||||
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
|
||||
|
||||
// Register document templates
|
||||
|
||||
CSingleDocTemplate* pDocTemplate;
|
||||
pDocTemplate = new CSingleDocTemplate(
|
||||
IDR_MAINFRAME,
|
||||
RUNTIME_CLASS(LdapDoc),
|
||||
RUNTIME_CLASS(CMainFrame), // main SDI frame window
|
||||
RUNTIME_CLASS(LdapView));
|
||||
AddDocTemplate(pDocTemplate);
|
||||
|
||||
#ifdef _WIN32
|
||||
// Parse command line for standard shell commands, DDE, file open
|
||||
CCommandLineInfo cmdInfo;
|
||||
ParseCommandLine(cmdInfo);
|
||||
|
||||
// Dispatch commands specified on the command line
|
||||
if (!ProcessShellCommand(cmdInfo))
|
||||
return FALSE;
|
||||
#else
|
||||
// create a new (empty) document
|
||||
OnFileNew();
|
||||
|
||||
if (m_lpCmdLine[0] != '\0')
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
m_dirHost = GetProfileString( "Connection", "host", "localhost" );
|
||||
m_dirPort = GetProfileInt( "Connection", "port", 389 );
|
||||
m_searchBase = GetProfileString( "Search", "base", "o=airius.com" );
|
||||
m_scope = GetProfileInt( "Search", "scope", LDAP_SCOPE_SUBTREE );
|
||||
m_searchFilter = GetProfileString( "Search", "filter", "objectclass=*" );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CAboutDlg dialog used for App About
|
||||
|
||||
class CAboutDlg : public CDialog
|
||||
{
|
||||
public:
|
||||
CAboutDlg();
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CAboutDlg)
|
||||
enum { IDD = IDD_ABOUTBOX };
|
||||
//}}AFX_DATA
|
||||
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CAboutDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
//{{AFX_MSG(CAboutDlg)
|
||||
// No message handlers
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CAboutDlg)
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CAboutDlg)
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CAboutDlg)
|
||||
// No message handlers
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
// App command to run the dialog
|
||||
void LdapApp::OnAppAbout()
|
||||
{
|
||||
CAboutDlg aboutDlg;
|
||||
aboutDlg.DoModal();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// LdapApp commands
|
||||
|
||||
// Initialize an anonymous connection to a Directory Server
|
||||
void LdapApp::OnFileConnect()
|
||||
{
|
||||
ConnDlg dlg;
|
||||
dlg.m_dirHost = m_dirHost;
|
||||
dlg.m_dirPort = m_dirPort;
|
||||
if ( IDOK == dlg.DoModal() )
|
||||
{
|
||||
m_dirHost = dlg.m_dirHost;
|
||||
m_dirPort = dlg.m_dirPort;
|
||||
m_ld = ldap_init( m_dirHost, m_dirPort );
|
||||
if ( NULL != m_ld )
|
||||
{
|
||||
// Bind as anonymous
|
||||
if ( ldap_bind_s( m_ld, "", "", LDAP_AUTH_SIMPLE )
|
||||
!= LDAP_SUCCESS )
|
||||
{
|
||||
AfxMessageBox( "Error binding!" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AfxMessageBox( "Error connecting!" );
|
||||
return;
|
||||
}
|
||||
m_connected = TRUE;
|
||||
LdapView *view = (LdapView *)((CFrameWnd *)AfxGetMainWnd())->GetActiveView();
|
||||
if ( view )
|
||||
{
|
||||
CString title;
|
||||
title.Format( "Host %s, port %d", m_dirHost, m_dirPort );
|
||||
view->GetDocument()->SetTitle( title );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LdapApp::OnUpdateFileConnect(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->Enable( !IsConnected() );
|
||||
}
|
||||
|
||||
// Disconnect (unbind from) a Directory Server
|
||||
void LdapApp::OnFileDisconnect()
|
||||
{
|
||||
ldap_unbind( m_ld );
|
||||
m_ld = NULL;
|
||||
m_connected = FALSE;
|
||||
LdapView *view = (LdapView *)((CFrameWnd *)AfxGetMainWnd())->GetActiveView();
|
||||
if ( view )
|
||||
{
|
||||
view->GetDocument()->SetTitle( "" );
|
||||
}
|
||||
}
|
||||
|
||||
void LdapApp::OnUpdateFileDisconnect(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->Enable( IsConnected() );
|
||||
}
|
||||
|
||||
// Search for and report distinguished names (no attributes)
|
||||
void LdapApp::OnFileSearch()
|
||||
{
|
||||
SearchDlg dlg;
|
||||
dlg.m_searchBase = m_searchBase;
|
||||
dlg.SetScope( m_scope );
|
||||
dlg.m_searchFilter = m_searchFilter;
|
||||
// Get desired search parameters
|
||||
if ( IDOK == dlg.DoModal() )
|
||||
{
|
||||
m_searchBase = dlg.m_searchBase;
|
||||
m_searchFilter = dlg.m_searchFilter;
|
||||
m_scope = dlg.GetScope();
|
||||
// Clear the result list
|
||||
LdapView *view = (LdapView *)((CFrameWnd *)AfxGetMainWnd())->GetActiveView();
|
||||
if ( view )
|
||||
view->ClearLines();
|
||||
char *attrs[2];
|
||||
// "dn" is a pseudo-attribute; it is always returned anyway, but not as
|
||||
// an attribute
|
||||
attrs[0] = "dn";
|
||||
attrs[1] = NULL;
|
||||
if ( ldap_search( m_ld, m_searchBase, m_scope, m_searchFilter,
|
||||
attrs, FALSE ) == -1 )
|
||||
{
|
||||
AfxMessageBox( "Failed to start asynchronous search" );
|
||||
return;
|
||||
}
|
||||
LDAPMessage *res;
|
||||
int rc;
|
||||
// Fetch all results as they become available
|
||||
while ( (rc = ldap_result( m_ld, LDAP_RES_ANY, 0, NULL, &res ))
|
||||
== LDAP_RES_SEARCH_ENTRY )
|
||||
{
|
||||
LDAPMessage *e = ldap_first_entry( m_ld, res );
|
||||
// Get the distinguished name and show it
|
||||
char *dn = ldap_get_dn( m_ld, e );
|
||||
if ( view )
|
||||
view->AddLine( dn, dn );
|
||||
ldap_memfree( dn );
|
||||
ldap_msgfree( res );
|
||||
// Let the view be updated
|
||||
#ifdef _WIN32
|
||||
Sleep( 0 );
|
||||
#else
|
||||
Yield();
|
||||
#endif
|
||||
}
|
||||
if ( rc == -1 )
|
||||
{
|
||||
AfxMessageBox( "Error on ldap_result" );
|
||||
return;
|
||||
}
|
||||
else if (( rc = ldap_result2error( m_ld, res, 0 )) != LDAP_SUCCESS )
|
||||
{
|
||||
char *errString = ldap_err2string( rc );
|
||||
AfxMessageBox( errString );
|
||||
}
|
||||
ldap_msgfree( res );
|
||||
}
|
||||
}
|
||||
|
||||
void LdapApp::OnUpdateFileSearch(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->Enable( IsConnected() );
|
||||
}
|
||||
|
||||
int LdapApp::ExitInstance()
|
||||
{
|
||||
WriteProfileString( "Connection", "host", m_dirHost );
|
||||
WriteProfileInt( "Connection", "port", m_dirPort );
|
||||
WriteProfileString( "Search", "base", m_searchBase );
|
||||
WriteProfileInt( "Search", "scope", m_scope );
|
||||
WriteProfileString( "Search", "filter", m_searchFilter );
|
||||
|
||||
return CWinApp::ExitInstance();
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
// winldap.h : main header file for the WINLDAP application
|
||||
//
|
||||
|
||||
#ifndef __AFXWIN_H__
|
||||
#error include 'stdafx.h' before including this file for PCH
|
||||
#endif
|
||||
|
||||
#include "resource.h" // main symbols
|
||||
|
||||
#ifndef _LDAP_H
|
||||
struct LDAP;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// LdapApp:
|
||||
// See winldap.cpp for the implementation of this class
|
||||
//
|
||||
|
||||
class LdapApp : public CWinApp
|
||||
{
|
||||
public:
|
||||
LdapApp();
|
||||
|
||||
public:
|
||||
BOOL IsConnected() { return m_connected; }
|
||||
LDAP *GetConnection() { return m_ld; }
|
||||
|
||||
private:
|
||||
BOOL m_connected;
|
||||
CString m_dirHost;
|
||||
int m_dirPort;
|
||||
CString m_searchBase;
|
||||
CString m_searchFilter;
|
||||
int m_scope;
|
||||
LDAP *m_ld;
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(LdapApp)
|
||||
public:
|
||||
virtual BOOL InitInstance();
|
||||
virtual int ExitInstance();
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
|
||||
//{{AFX_MSG(LdapApp)
|
||||
afx_msg void OnAppAbout();
|
||||
afx_msg void OnFileConnect();
|
||||
afx_msg void OnUpdateFileConnect(CCmdUI* pCmdUI);
|
||||
afx_msg void OnFileDisconnect();
|
||||
afx_msg void OnUpdateFileDisconnect(CCmdUI* pCmdUI);
|
||||
afx_msg void OnFileSearch();
|
||||
afx_msg void OnUpdateFileSearch(CCmdUI* pCmdUI);
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,404 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=winldap - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to winldap - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "winldap - Win32 Release" && "$(CFG)" !=\
|
||||
"winldap - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE on this makefile
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "winldap.mak" CFG="winldap - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "winldap - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "winldap - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
################################################################################
|
||||
# Begin Project
|
||||
# PROP Target_Last_Scanned "winldap - Win32 Debug"
|
||||
MTL=mktyplib.exe
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "winldap - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 6
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 6
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
|
||||
ALL : "$(OUTDIR)\winldap.exe"
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\ConnDlg.obj"
|
||||
-@erase "$(INTDIR)\LdapDoc.obj"
|
||||
-@erase "$(INTDIR)\LdapView.obj"
|
||||
-@erase "$(INTDIR)\MainFrm.obj"
|
||||
-@erase "$(INTDIR)\PropDlg.obj"
|
||||
-@erase "$(INTDIR)\SrchDlg.obj"
|
||||
-@erase "$(INTDIR)\StdAfx.obj"
|
||||
-@erase "$(INTDIR)\winldap.obj"
|
||||
-@erase "$(INTDIR)\winldap.pch"
|
||||
-@erase "$(INTDIR)\winldap.res"
|
||||
-@erase "$(OUTDIR)\winldap.exe"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
|
||||
CPP_PROJ=/nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\
|
||||
"_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/winldap.pch" /Yu"stdafx.h" /Fo"$(INTDIR)/"\
|
||||
/c
|
||||
CPP_OBJS=.\Release/
|
||||
CPP_SBRS=.\.
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /win32
|
||||
MTL_PROJ=/nologo /D "NDEBUG" /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)/winldap.res" /d "NDEBUG" /d "_AFXDLL"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)/winldap.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 nsldapssl32v30.lib /nologo /subsystem:windows /machine:I386
|
||||
LINK32_FLAGS=nsldapssl32v30.lib /nologo /subsystem:windows /incremental:no\
|
||||
/pdb:"$(OUTDIR)/winldap.pdb" /machine:I386 /out:"$(OUTDIR)/winldap.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\ConnDlg.obj" \
|
||||
"$(INTDIR)\LdapDoc.obj" \
|
||||
"$(INTDIR)\LdapView.obj" \
|
||||
"$(INTDIR)\MainFrm.obj" \
|
||||
"$(INTDIR)\PropDlg.obj" \
|
||||
"$(INTDIR)\SrchDlg.obj" \
|
||||
"$(INTDIR)\StdAfx.obj" \
|
||||
"$(INTDIR)\winldap.obj" \
|
||||
"$(INTDIR)\winldap.res"
|
||||
|
||||
"$(OUTDIR)\winldap.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "winldap - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 6
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 6
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
|
||||
ALL : "$(OUTDIR)\winldap.exe"
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\ConnDlg.obj"
|
||||
-@erase "$(INTDIR)\LdapDoc.obj"
|
||||
-@erase "$(INTDIR)\LdapView.obj"
|
||||
-@erase "$(INTDIR)\MainFrm.obj"
|
||||
-@erase "$(INTDIR)\PropDlg.obj"
|
||||
-@erase "$(INTDIR)\SrchDlg.obj"
|
||||
-@erase "$(INTDIR)\StdAfx.obj"
|
||||
-@erase "$(INTDIR)\vc40.idb"
|
||||
-@erase "$(INTDIR)\vc40.pdb"
|
||||
-@erase "$(INTDIR)\winldap.obj"
|
||||
-@erase "$(INTDIR)\winldap.pch"
|
||||
-@erase "$(INTDIR)\winldap.res"
|
||||
-@erase "$(OUTDIR)\winldap.exe"
|
||||
-@erase "$(OUTDIR)\winldap.ilk"
|
||||
-@erase "$(OUTDIR)\winldap.pdb"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
|
||||
CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS"\
|
||||
/D "_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/winldap.pch" /Yu"stdafx.h"\
|
||||
/Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
|
||||
CPP_OBJS=.\Debug/
|
||||
CPP_SBRS=.\.
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /win32
|
||||
MTL_PROJ=/nologo /D "_DEBUG" /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)/winldap.res" /d "_DEBUG" /d "_AFXDLL"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)/winldap.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386
|
||||
# ADD LINK32 nsldapssl32v30.lib /nologo /subsystem:windows /debug /machine:I386
|
||||
LINK32_FLAGS=nsldapssl32v30.lib /nologo /subsystem:windows /incremental:yes\
|
||||
/pdb:"$(OUTDIR)/winldap.pdb" /debug /machine:I386 /out:"$(OUTDIR)/winldap.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\ConnDlg.obj" \
|
||||
"$(INTDIR)\LdapDoc.obj" \
|
||||
"$(INTDIR)\LdapView.obj" \
|
||||
"$(INTDIR)\MainFrm.obj" \
|
||||
"$(INTDIR)\PropDlg.obj" \
|
||||
"$(INTDIR)\SrchDlg.obj" \
|
||||
"$(INTDIR)\StdAfx.obj" \
|
||||
"$(INTDIR)\winldap.obj" \
|
||||
"$(INTDIR)\winldap.res"
|
||||
|
||||
"$(OUTDIR)\winldap.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
.c{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.c{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
################################################################################
|
||||
# Begin Target
|
||||
|
||||
# Name "winldap - Win32 Release"
|
||||
# Name "winldap - Win32 Debug"
|
||||
|
||||
!IF "$(CFG)" == "winldap - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "winldap - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\winldap.cpp
|
||||
DEP_CPP_WINLD=\
|
||||
".\ConnDlg.h"\
|
||||
".\LdapDoc.h"\
|
||||
".\LdapView.h"\
|
||||
".\MainFrm.h"\
|
||||
".\SrchDlg.h"\
|
||||
".\StdAfx.h"\
|
||||
".\winldap.h"\
|
||||
"d:\projects\ldapsdk\include\lber.h"\
|
||||
{$(INCLUDE)}"\ldap.h"\
|
||||
{$(INCLUDE)}"\sys\time.h"\
|
||||
{$(INCLUDE)}"\sys\types.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\winldap.obj" : $(SOURCE) $(DEP_CPP_WINLD) "$(INTDIR)"\
|
||||
"$(INTDIR)\winldap.pch"
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.cpp
|
||||
DEP_CPP_STDAF=\
|
||||
".\StdAfx.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "winldap - Win32 Release"
|
||||
|
||||
# ADD CPP /Yc"stdafx.h"
|
||||
|
||||
BuildCmds= \
|
||||
$(CPP) /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\
|
||||
"_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/winldap.pch" /Yc"stdafx.h" /Fo"$(INTDIR)/"\
|
||||
/c $(SOURCE) \
|
||||
|
||||
|
||||
"$(INTDIR)\StdAfx.obj" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(INTDIR)\winldap.pch" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
!ELSEIF "$(CFG)" == "winldap - Win32 Debug"
|
||||
|
||||
# ADD CPP /Yc"stdafx.h"
|
||||
|
||||
BuildCmds= \
|
||||
$(CPP) /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS"\
|
||||
/D "_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/winldap.pch" /Yc"stdafx.h"\
|
||||
/Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c $(SOURCE) \
|
||||
|
||||
|
||||
"$(INTDIR)\StdAfx.obj" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(INTDIR)\winldap.pch" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MainFrm.cpp
|
||||
DEP_CPP_MAINF=\
|
||||
".\MainFrm.h"\
|
||||
".\StdAfx.h"\
|
||||
".\winldap.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\MainFrm.obj" : $(SOURCE) $(DEP_CPP_MAINF) "$(INTDIR)"\
|
||||
"$(INTDIR)\winldap.pch"
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\LdapDoc.cpp
|
||||
DEP_CPP_LDAPD=\
|
||||
".\LdapDoc.h"\
|
||||
".\StdAfx.h"\
|
||||
".\winldap.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\LdapDoc.obj" : $(SOURCE) $(DEP_CPP_LDAPD) "$(INTDIR)"\
|
||||
"$(INTDIR)\winldap.pch"
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\LdapView.cpp
|
||||
DEP_CPP_LDAPV=\
|
||||
".\LdapDoc.h"\
|
||||
".\LdapView.h"\
|
||||
".\PropDlg.h"\
|
||||
".\StdAfx.h"\
|
||||
".\winldap.h"\
|
||||
"d:\projects\ldapsdk\include\lber.h"\
|
||||
{$(INCLUDE)}"\ldap.h"\
|
||||
{$(INCLUDE)}"\sys\time.h"\
|
||||
{$(INCLUDE)}"\sys\types.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\LdapView.obj" : $(SOURCE) $(DEP_CPP_LDAPV) "$(INTDIR)"\
|
||||
"$(INTDIR)\winldap.pch"
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\winldap.rc
|
||||
DEP_RSC_WINLDA=\
|
||||
".\res\LdapDoc.ico"\
|
||||
".\res\winldap.ico"\
|
||||
".\res\winldap.rc2"\
|
||||
|
||||
|
||||
"$(INTDIR)\winldap.res" : $(SOURCE) $(DEP_RSC_WINLDA) "$(INTDIR)"
|
||||
$(RSC) $(RSC_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ConnDlg.cpp
|
||||
DEP_CPP_CONND=\
|
||||
".\ConnDlg.h"\
|
||||
".\StdAfx.h"\
|
||||
".\winldap.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\ConnDlg.obj" : $(SOURCE) $(DEP_CPP_CONND) "$(INTDIR)"\
|
||||
"$(INTDIR)\winldap.pch"
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SrchDlg.cpp
|
||||
DEP_CPP_SRCHD=\
|
||||
".\SrchDlg.h"\
|
||||
".\StdAfx.h"\
|
||||
".\winldap.h"\
|
||||
"d:\projects\ldapsdk\include\lber.h"\
|
||||
{$(INCLUDE)}"\ldap.h"\
|
||||
{$(INCLUDE)}"\sys\time.h"\
|
||||
{$(INCLUDE)}"\sys\types.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\SrchDlg.obj" : $(SOURCE) $(DEP_CPP_SRCHD) "$(INTDIR)"\
|
||||
"$(INTDIR)\winldap.pch"
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PropDlg.cpp
|
||||
DEP_CPP_PROPD=\
|
||||
".\PropDlg.h"\
|
||||
".\StdAfx.h"\
|
||||
".\winldap.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\PropDlg.obj" : $(SOURCE) $(DEP_CPP_PROPD) "$(INTDIR)"\
|
||||
"$(INTDIR)\winldap.pch"
|
||||
|
||||
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
################################################################################
|
||||
406
mozilla/directory/c-sdk/ldap/examples/windows/winldap/winldap.rc
Normal file
406
mozilla/directory/c-sdk/ldap/examples/windows/winldap/winldap.rc
Normal file
@@ -0,0 +1,406 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
|
||||
"#define _AFX_NO_OLE_RESOURCES\r\n"
|
||||
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
|
||||
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
|
||||
"\r\n"
|
||||
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
|
||||
"#ifdef _WIN32\r\n"
|
||||
"LANGUAGE 9, 1\r\n"
|
||||
"#pragma code_page(1252)\r\n"
|
||||
"#endif\r\n"
|
||||
"#include ""res\\winldap.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
|
||||
"#include ""afxres.rc"" // Standard components\r\n"
|
||||
"#endif\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDR_MAINFRAME ICON DISCARDABLE "res\\winldap.ico"
|
||||
IDR_WINLDATYPE ICON DISCARDABLE "res\\LdapDoc.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
IDR_MAINFRAME MENU PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&Connect...\tCtrl+N", ID_FILE_CONNECT
|
||||
MENUITEM "&Disconnect\tCtrl+D", ID_FILE_DISCONNECT
|
||||
MENUITEM "&Search...\tCtrl+S", ID_FILE_SEARCH
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", ID_APP_EXIT
|
||||
END
|
||||
POPUP "&View"
|
||||
BEGIN
|
||||
MENUITEM "&Toolbar", ID_VIEW_TOOLBAR
|
||||
MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&About winldap...", ID_APP_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
|
||||
BEGIN
|
||||
"N", ID_FILE_NEW, VIRTKEY, CONTROL
|
||||
"O", ID_FILE_OPEN, VIRTKEY, CONTROL
|
||||
"S", ID_FILE_SAVE, VIRTKEY, CONTROL
|
||||
"Z", ID_EDIT_UNDO, VIRTKEY, CONTROL
|
||||
"X", ID_EDIT_CUT, VIRTKEY, CONTROL
|
||||
"C", ID_EDIT_COPY, VIRTKEY, CONTROL
|
||||
"V", ID_EDIT_PASTE, VIRTKEY, CONTROL
|
||||
VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT
|
||||
VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT
|
||||
VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL
|
||||
VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT
|
||||
VK_F6, ID_NEXT_PANE, VIRTKEY
|
||||
VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 217, 55
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "About winldap"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
ICON IDR_MAINFRAME,IDC_STATIC,11,17,21,20
|
||||
LTEXT "WinLdap - sample LDAP client",IDC_STATIC,40,10,119,8,
|
||||
SS_NOPREFIX
|
||||
LTEXT "Copyright © 1997",IDC_STATIC,40,25,119,8
|
||||
DEFPUSHBUTTON "OK",IDOK,178,7,32,14,WS_GROUP
|
||||
END
|
||||
|
||||
IDD_CONNECT_DIALOG DIALOG DISCARDABLE 0, 0, 186, 76
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Connect to Directory Server"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,35,55,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,103,55,50,14
|
||||
RTEXT "Host name:",IDC_STATIC,21,17,52,12
|
||||
EDITTEXT IDC_DIR_PORT,79,33,92,14,ES_AUTOHSCROLL
|
||||
RTEXT "Port number:",IDC_STATIC,28,36,45,12
|
||||
EDITTEXT IDC_DIR_HOST,79,14,92,14,ES_AUTOHSCROLL
|
||||
END
|
||||
|
||||
IDD_SEARCH_DIALOG DIALOG DISCARDABLE 0, 0, 186, 103
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Search parameters"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,39,82,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,105,82,50,14
|
||||
RTEXT "Directory base:",IDC_STATIC,7,16,54,12
|
||||
EDITTEXT IDC_SEARCH_BASE,65,13,106,14,ES_AUTOHSCROLL
|
||||
RTEXT "Search filter:",IDC_STATIC,10,34,51,12
|
||||
EDITTEXT IDC_SEARCH_FILTER,65,31,105,14,ES_AUTOHSCROLL
|
||||
CONTROL "Base",IDC_SCOPE_BASE,"Button",BS_AUTORADIOBUTTON,23,60,
|
||||
32,10
|
||||
CONTROL "One level",IDC_SCOPE_ONE,"Button",BS_AUTORADIOBUTTON,69,
|
||||
60,46,10
|
||||
CONTROL "Subtree",IDC_SCOPE_SUB,"Button",BS_AUTORADIOBUTTON,121,
|
||||
60,41,10
|
||||
GROUPBOX "Scope",IDC_STATIC,13,49,159,24
|
||||
END
|
||||
|
||||
IDD_ENTRY_PROPERTIES DIALOG DISCARDABLE 0, 0, 273, 202
|
||||
STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Properties"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
END
|
||||
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,1
|
||||
PRODUCTVERSION 1,0,0,1
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x4L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "\0"
|
||||
VALUE "FileDescription", "WINLDAP MFC Application\0"
|
||||
VALUE "FileVersion", "1, 0, 0, 1\0"
|
||||
VALUE "InternalName", "WINLDAP\0"
|
||||
VALUE "LegalCopyright", "Copyright © 1997\0"
|
||||
VALUE "OriginalFilename", "WINLDAP.EXE\0"
|
||||
VALUE "ProductName", "WINLDAP Application\0"
|
||||
VALUE "ProductVersion", "1, 0, 0, 1\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // !_MAC
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_ABOUTBOX, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 210
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 48
|
||||
END
|
||||
|
||||
IDD_CONNECT_DIALOG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 179
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 69
|
||||
END
|
||||
|
||||
IDD_SEARCH_DIALOG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 179
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 96
|
||||
END
|
||||
|
||||
IDD_ENTRY_PROPERTIES, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 266
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 195
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
IDR_MAINFRAME "winldap\n\nWinlda\n\n\nWinldap.Document\nWinlda Document"
|
||||
END
|
||||
|
||||
STRINGTABLE PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_APP_TITLE "winldap"
|
||||
AFX_IDS_IDLEMESSAGE "Ready"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_INDICATOR_EXT "EXT"
|
||||
ID_INDICATOR_CAPS "CAP"
|
||||
ID_INDICATOR_NUM "NUM"
|
||||
ID_INDICATOR_SCRL "SCRL"
|
||||
ID_INDICATOR_OVR "OVR"
|
||||
ID_INDICATOR_REC "REC"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_FILE_NEW "Create a new document\nNew"
|
||||
ID_FILE_OPEN "Open an existing document\nOpen"
|
||||
ID_FILE_CLOSE "Close the active document\nClose"
|
||||
ID_FILE_SAVE "Save the active document\nSave"
|
||||
ID_FILE_SAVE_AS "Save the active document with a new name\nSave As"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_APP_ABOUT "Display program information, version number and copyright\nAbout"
|
||||
ID_APP_EXIT "Quit the application; prompts to save documents\nExit"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_FILE_MRU_FILE1 "Open this document"
|
||||
ID_FILE_MRU_FILE2 "Open this document"
|
||||
ID_FILE_MRU_FILE3 "Open this document"
|
||||
ID_FILE_MRU_FILE4 "Open this document"
|
||||
ID_FILE_MRU_FILE5 "Open this document"
|
||||
ID_FILE_MRU_FILE6 "Open this document"
|
||||
ID_FILE_MRU_FILE7 "Open this document"
|
||||
ID_FILE_MRU_FILE8 "Open this document"
|
||||
ID_FILE_MRU_FILE9 "Open this document"
|
||||
ID_FILE_MRU_FILE10 "Open this document"
|
||||
ID_FILE_MRU_FILE11 "Open this document"
|
||||
ID_FILE_MRU_FILE12 "Open this document"
|
||||
ID_FILE_MRU_FILE13 "Open this document"
|
||||
ID_FILE_MRU_FILE14 "Open this document"
|
||||
ID_FILE_MRU_FILE15 "Open this document"
|
||||
ID_FILE_MRU_FILE16 "Open this document"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_NEXT_PANE "Switch to the next window pane\nNext Pane"
|
||||
ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_WINDOW_SPLIT "Split the active window into panes\nSplit"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_EDIT_CLEAR "Erase the selection\nErase"
|
||||
ID_EDIT_CLEAR_ALL "Erase everything\nErase All"
|
||||
ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy"
|
||||
ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut"
|
||||
ID_EDIT_FIND "Find the specified text\nFind"
|
||||
ID_EDIT_PASTE "Insert Clipboard contents\nPaste"
|
||||
ID_EDIT_REPEAT "Repeat the last action\nRepeat"
|
||||
ID_EDIT_REPLACE "Replace specific text with different text\nReplace"
|
||||
ID_EDIT_SELECT_ALL "Select the entire document\nSelect All"
|
||||
ID_EDIT_UNDO "Undo the last action\nUndo"
|
||||
ID_EDIT_REDO "Redo the previously undone action\nRedo"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar"
|
||||
ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_SCSIZE "Change the window size"
|
||||
AFX_IDS_SCMOVE "Change the window position"
|
||||
AFX_IDS_SCMINIMIZE "Reduce the window to an icon"
|
||||
AFX_IDS_SCMAXIMIZE "Enlarge the window to full size"
|
||||
AFX_IDS_SCNEXTWINDOW "Switch to the next document window"
|
||||
AFX_IDS_SCPREVWINDOW "Switch to the previous document window"
|
||||
AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_SCRESTORE "Restore the window to normal size"
|
||||
AFX_IDS_SCTASKLIST "Activate Task List"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_FILE_CONNECT "Connect to Directory Server"
|
||||
ID_FILE_DISCONNECT "Disconnect from Directory Server"
|
||||
ID_FILE_SEARCH "Search in Directory"
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
#define _AFX_NO_SPLITTER_RESOURCES
|
||||
#define _AFX_NO_OLE_RESOURCES
|
||||
#define _AFX_NO_TRACKER_RESOURCES
|
||||
#define _AFX_NO_PROPERTY_RESOURCES
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE 9, 1
|
||||
#pragma code_page(1252)
|
||||
#endif
|
||||
#include "res\winldap.rc2" // non-Microsoft Visual C++ edited resources
|
||||
#include "afxres.rc" // Standard components
|
||||
#endif
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
43
mozilla/directory/c-sdk/ldap/examples/xmplflt.conf
Normal file
43
mozilla/directory/c-sdk/ldap/examples/xmplflt.conf
Normal file
@@ -0,0 +1,43 @@
|
||||
# example ldap filter file
|
||||
#
|
||||
# lines like this that start with # or empty lines are ignored
|
||||
#
|
||||
# syntax:
|
||||
#
|
||||
# <tag>
|
||||
# <pattern1> <delimiters> <filter1-1> <desc1-1> [<scope>]
|
||||
# <filter1-2> <desc1-2> [<scope>]
|
||||
#
|
||||
# <pattern2> <delimiters> <filter2-1> <desc2-1> [<scope>] ...
|
||||
#
|
||||
# The "desc" should describe the filter and it should correctly complete
|
||||
# both of the following phrases:
|
||||
#
|
||||
# One <desc> match was found for...
|
||||
# Three <desc> matches were found for...
|
||||
#
|
||||
# The scope is optional, and should be one of:
|
||||
# "base"
|
||||
# "onelevel"
|
||||
# "subtree"
|
||||
# if it is included.
|
||||
#
|
||||
|
||||
"ldap-example"
|
||||
"=" " " "%v" "arbitrary filter"
|
||||
|
||||
"^[+]*[0-9][ 0-9-]*$" " " "(telephoneNumber=*%v)" "phone number"
|
||||
|
||||
"@" " " "(mail=%v)" "email address"
|
||||
"(mail=%v*)" "start of email address"
|
||||
|
||||
"^.[. _].*" ". _" "(cn=%v1* %v2-)" "first initial"
|
||||
|
||||
".*[. _].$" ". _" "(cn=%v1-*)" "last initial"
|
||||
|
||||
"[. _]" ". _" "(|(sn=%v1-)(cn=%v1-))" "exact"
|
||||
"(|(sn~=%v1-)(cn~=%v1-))" "approximate"
|
||||
|
||||
".*" ". " "(|(cn=%v1)(sn=%v1)(uid=%v1))" "exact"
|
||||
"(|(cn~=%v1)(sn~=%v1))" "approximate"
|
||||
|
||||
4
mozilla/directory/c-sdk/ldap/include/MANIFEST
Normal file
4
mozilla/directory/c-sdk/ldap/include/MANIFEST
Normal file
@@ -0,0 +1,4 @@
|
||||
disptmpl.h
|
||||
lber.h
|
||||
ldap.h
|
||||
srchpref.h
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user