mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Renamed Makefiles. Added Frith-MacDonald patch fixing NSUserDefaults.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2603 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d168026dab
commit
827436f054
26 changed files with 867 additions and 411 deletions
55
ChangeLog
55
ChangeLog
|
@ -1,3 +1,58 @@
|
||||||
|
Fri Oct 31 10:26:16 1997 Adam Fedor <fedor@doc.com>
|
||||||
|
|
||||||
|
* GNUmakefile: Renamed from Makefile.
|
||||||
|
* src/GNUmakefile: Likewise.
|
||||||
|
* checks/GNUmakefile: Likewise.
|
||||||
|
* examples/GNUmakefile: Likewise.
|
||||||
|
* doc/GNUmakefile: Likewise.
|
||||||
|
* admin/GNUmakefile: Likewise.
|
||||||
|
* NSCharacterSets/GNUmakefile: Likewise.
|
||||||
|
* NSTimeZones/GNUmakefile: Likewise.
|
||||||
|
* Makefile: Dummy make, tells user to use GNU make.
|
||||||
|
|
||||||
|
* doc/GNUMakefile: Make more text files.
|
||||||
|
* doc/Makefile.postamble: Clean up to make text files.
|
||||||
|
|
||||||
|
* NSBundle.README: Update.
|
||||||
|
* examples/Makefile.example.in: Remove obsolete file.
|
||||||
|
* examples/configure.example.in: Likewise.
|
||||||
|
|
||||||
|
Thu Oct 30 15:20:00 1997 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
|
* Tools/GNUmakefile: New format make file with the addition of three
|
||||||
|
new tools - dread, dwrite, dremove
|
||||||
|
|
||||||
|
* Tools/dread.m: New command line tool to read user defaults database.
|
||||||
|
* Tools/dremove.m: New command line tool to remove defaults from
|
||||||
|
database.
|
||||||
|
* Tools/dwrite.m: New command line tool to modify user defaults.
|
||||||
|
|
||||||
|
* src/Dictionary.m: ([-descriptionWithIndent:]) modified to produce
|
||||||
|
better property-list type description with escaped special chars.
|
||||||
|
|
||||||
|
* src/NSArray.m: ([-description]) modified to produce better
|
||||||
|
property-list type description with escaped special chars.
|
||||||
|
|
||||||
|
* src/NSData.m: ([-writeToFile:atomically:]) changed code for handling
|
||||||
|
temporary file to avoid failure due to cross-device links.
|
||||||
|
|
||||||
|
* src/NSDictionary.m: ([-writeToFile:atomically:]) implemented this
|
||||||
|
method using NSString.
|
||||||
|
|
||||||
|
* src/NSString.m: ([-stringByAppendingString:]) fixed memory leak.
|
||||||
|
Added new method ([-quotedCString]) for use in writing property lists.
|
||||||
|
Modified ([-appendFormat:]) so that it doesn't leave temporary strings
|
||||||
|
to be autoreleased - small efficiency gain.
|
||||||
|
|
||||||
|
* src/NSUserDefaults.m: Various minor fixes to get saving to the
|
||||||
|
defaults database to work.
|
||||||
|
|
||||||
|
* src/Foundation/NSString.h: Added (GNUstep specific) method -
|
||||||
|
[-quotedCString].
|
||||||
|
|
||||||
|
* src/Foundation/NSUserDefaults.h: Added (OPENSTEP specific) method -
|
||||||
|
[-setSearchList:].
|
||||||
|
|
||||||
Thu Oct 30 13:38:51 1997 Scott Christley <scottc@stetson.net-community.com>
|
Thu Oct 30 13:38:51 1997 Scott Christley <scottc@stetson.net-community.com>
|
||||||
|
|
||||||
* Makefile (GNUSTEP_INSTALLATION_DIR): Make default be system.
|
* Makefile (GNUSTEP_INSTALLATION_DIR): Make default be system.
|
||||||
|
|
|
@ -30,6 +30,7 @@ include ../config.mak
|
||||||
|
|
||||||
MAKEINFO = makeinfo
|
MAKEINFO = makeinfo
|
||||||
TEXI2DVI = texi2dvi
|
TEXI2DVI = texi2dvi
|
||||||
|
TEXI2HTML = texi2html
|
||||||
|
|
||||||
TEXI_FILES = \
|
TEXI_FILES = \
|
||||||
announce.texi \
|
announce.texi \
|
||||||
|
@ -49,12 +50,16 @@ version.texi \
|
||||||
NSZone.texi
|
NSZone.texi
|
||||||
|
|
||||||
TEXT_FILES = \
|
TEXT_FILES = \
|
||||||
TODO INSTALL NEWS CODING-STANDARDS README ANNOUNCE ADVERTISEMENT
|
TODO INSTALL NEWS CODING-STANDARDS README ANNOUNCE ADVERTISEMENT \
|
||||||
|
GNUstep-FAQ
|
||||||
|
INFO_FILES = gnustep-base.info
|
||||||
|
PS_FILES = gnustep-base.dvi
|
||||||
|
HTML_FILES =
|
||||||
|
DVI_FILES = gnustep-base.dvi objective-c.dvi
|
||||||
|
|
||||||
TOP_DOC_FILES = README INSTALL NEWS
|
TOP_DOC_FILES = README INSTALL NEWS
|
||||||
RCS_FILES = $(TEXI_FILES) Makefile Makefile.postamble
|
RCS_FILES = $(TEXI_FILES) Makefile Makefile.postamble
|
||||||
DIST_FILES = $(RCS_FILES) texinfo.tex \
|
DIST_FILES = $(RCS_FILES) texinfo.tex $(TEXT_FILES)
|
||||||
$(TOP_DOC_FILES) ANNOUNCE ADVERTISEMENT TODO
|
|
||||||
|
|
||||||
-include Makefile.preamble
|
-include Makefile.preamble
|
||||||
|
|
||||||
|
@ -63,3 +68,7 @@ DIST_FILES = $(RCS_FILES) texinfo.tex \
|
||||||
include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/rules.make
|
include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/rules.make
|
||||||
|
|
||||||
-include Makefile.postamble
|
-include Makefile.postamble
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -81,8 +81,13 @@ after-clean::
|
||||||
|
|
||||||
srcdir=.
|
srcdir=.
|
||||||
|
|
||||||
info: version.texi $(TEXT_FILES)
|
all:: text
|
||||||
dvi: gnustep-base.dvi objective-c.dvi
|
|
||||||
|
text: $(TEXT_FILES)
|
||||||
|
info: version.texi $(INFO_FILES)
|
||||||
|
ps: $(PS_FILES)
|
||||||
|
html: $(HTML_FILES)
|
||||||
|
dvi: $(DVI_FILES)
|
||||||
|
|
||||||
version.texi: $(srcdir)/../Version
|
version.texi: $(srcdir)/../Version
|
||||||
rm -f version.texi
|
rm -f version.texi
|
||||||
|
@ -116,7 +121,7 @@ TODO: todo.texi version.texi
|
||||||
INSTALL: install.texi version.texi
|
INSTALL: install.texi version.texi
|
||||||
$(MAKEINFO) $(MAKEINFO_FLAGS) -o INSTALL -D INSTALL_ONLY \
|
$(MAKEINFO) $(MAKEINFO_FLAGS) -o INSTALL -D INSTALL_ONLY \
|
||||||
--no-header --no-split $(srcdir)/install.texi
|
--no-header --no-split $(srcdir)/install.texi
|
||||||
CODING-STANDARDS: codign-standards.texi version.texi
|
CODING-STANDARDS: coding-standards.texi version.texi
|
||||||
$(MAKEINFO) $(MAKEINFO_FLAGS) -o CODING-STANDARDS -D CODING_ONLY \
|
$(MAKEINFO) $(MAKEINFO_FLAGS) -o CODING-STANDARDS -D CODING_ONLY \
|
||||||
--no-header --no-split $(srcdir)/coding-standards.texi
|
--no-header --no-split $(srcdir)/coding-standards.texi
|
||||||
README: readme.texi version.texi
|
README: readme.texi version.texi
|
||||||
|
|
|
@ -1,96 +0,0 @@
|
||||||
#
|
|
||||||
# Examples makefile example for Objective-C Class Library
|
|
||||||
# Copyright (C) 1993, 1995 Free Software Foundation, Inc.
|
|
||||||
#
|
|
||||||
# Written by: Adam Fedor <fedor@boulder.colorado.edu>
|
|
||||||
#
|
|
||||||
# This file is part of the GNU Objective-C Class Library.
|
|
||||||
#
|
|
||||||
# This library is free software; you can redistribute it and/or
|
|
||||||
# modify it under the terms of the GNU Library General Public
|
|
||||||
# License as published by the Free Software Foundation; either
|
|
||||||
# version 2 of the License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This library is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
# Library General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Library General Public
|
|
||||||
# License along with this library; if not, write to the Free
|
|
||||||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
|
|
||||||
SHELL = /bin/sh
|
|
||||||
|
|
||||||
#### Start of system configuration section. ####
|
|
||||||
|
|
||||||
srcdir = @srcdir@
|
|
||||||
VPATH = @srcdir@
|
|
||||||
|
|
||||||
CC = @CC@
|
|
||||||
|
|
||||||
CFLAGS = @CFLAGS@ -Wall -Wno-implicit
|
|
||||||
CPPFLAGS =
|
|
||||||
LDFLAGS =
|
|
||||||
|
|
||||||
DYNAMIC_BUNDLER_LINKER=@DYNAMIC_BUNDLER_LINKER@
|
|
||||||
DYNAMIC_LDFLAGS=@DYNAMIC_LDFLAGS@
|
|
||||||
DYNAMIC_CFLAGS=@DYNAMIC_CFLAGS@
|
|
||||||
DEFS = @DEFS@
|
|
||||||
LIBS = @LIBS@
|
|
||||||
|
|
||||||
#### End of system configuration section. ####
|
|
||||||
|
|
||||||
ALL_CPPFLAGS = $(CPPFLAGS)
|
|
||||||
ALL_CFLAGS = $(CFLAGS)
|
|
||||||
ALL_OBJCFLAGS = $(CFLAGS) -Wno-protocol
|
|
||||||
ALL_LDFLAGS = $(LDFLAGS)
|
|
||||||
|
|
||||||
.SUFFIXES: .m
|
|
||||||
.m.o:
|
|
||||||
$(CC) -c $(ALL_CPPFLAGS) $(DEFS) $(ALL_OBJCFLAGS) $< -o $*.o
|
|
||||||
.c.o:
|
|
||||||
$(CC) -c $(ALL_CPPFLAGS) $(DEFS) $(ALL_CFLAGS) $< -o $*.o
|
|
||||||
|
|
||||||
EXCS = myprogram
|
|
||||||
SOURCES = myprogram.m MyObject.m
|
|
||||||
OFILES = $(SOURCES:.m=.o)
|
|
||||||
|
|
||||||
BUNDLE_NAME=LoadMe
|
|
||||||
DYNAMIC_MFILES =
|
|
||||||
DYNAMIC_OFILES = $(DYNAMIC_MFILES:.m=.o)
|
|
||||||
|
|
||||||
all: $(EXCS) bundles
|
|
||||||
|
|
||||||
myprogram: $(OFILES)
|
|
||||||
$(CC) $(ALL_LDFLAGS) -o myprogram $(OFILES) $(LIBS)
|
|
||||||
|
|
||||||
install:
|
|
||||||
uninstall:
|
|
||||||
|
|
||||||
# These next few lines give an example of how to compile, link and store
|
|
||||||
# a bundle.
|
|
||||||
bundles: $(BUNDLE_NAME).bundle/$(BUNDLE_NAME)
|
|
||||||
|
|
||||||
$(DYNAMIC_OFILES): $(DYNAMIC_MFILES) $(DYNAMIC_HFILES)
|
|
||||||
$(CC) -c $(ALL_CPPFLAGS) $(DEFS) $(DYNAMIC_CFLAGS) $(ALL_OBJCFLAGS) \
|
|
||||||
$*.m -o $*.o
|
|
||||||
|
|
||||||
$(BUNDLE_NAME).bundle/$(BUNDLE_NAME): $(DYNAMIC_OFILES)
|
|
||||||
-mkdir $(BUNDLE_NAME).bundle
|
|
||||||
-mkdir $(BUNDLE_NAME).bundle/English.lproj
|
|
||||||
$(DYNAMIC_BUNDLER_LINKER) -o $(BUNDLE_NAME).bundle/$(BUNDLE_NAME) \
|
|
||||||
$(DYNAMIC_OFILES)
|
|
||||||
|
|
||||||
mostlyclean:
|
|
||||||
rm -f core *~
|
|
||||||
|
|
||||||
clean: mostlyclean
|
|
||||||
rm -f *.o $(EXCS)
|
|
||||||
rm -rf $(BUNDLE_NAME).bundle
|
|
||||||
|
|
||||||
distclean: clean
|
|
||||||
rm -f Makefile config.status
|
|
||||||
|
|
||||||
realclean: distclean
|
|
||||||
rm -f TAGS
|
|
|
@ -1,190 +0,0 @@
|
||||||
AC_INIT(configure.example.in)
|
|
||||||
# Example configure.in for configuring projects that use libobjects.
|
|
||||||
#
|
|
||||||
# Copyright (C) 1995 Free Software Foundation, Inc.
|
|
||||||
#
|
|
||||||
# Written by: Adam Fedor <fedor@mode.colorado.edu>
|
|
||||||
# This file is part of the GNU Objective-C library.
|
|
||||||
#
|
|
||||||
# This library is free software; you can redistribute it and/or
|
|
||||||
# modify it under the terms of the GNU Library General Public
|
|
||||||
# License as published by the Free Software Foundation; either
|
|
||||||
# version 2 of the License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This library is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
# Library General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Library General Public
|
|
||||||
# License along with this library; if not, write to the Free
|
|
||||||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
#
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# You should customize this file for your own project, and process it
|
|
||||||
# using the autoconf program (available from any GNU software site) to
|
|
||||||
# add automatic configuration to your project. Make sure you have copied
|
|
||||||
# the file "aclocal.m4" from the libobjects distribution into the same
|
|
||||||
# directory as this file. Rename this file to "configure.in" and
|
|
||||||
# customize it for your own project. Then simply type
|
|
||||||
# "autoconf configure.in" at the command line to create the file
|
|
||||||
# "configure". You need to distribute the files "configure" and
|
|
||||||
# "Makefile.in" (which you have customized from Makefile.example.in).
|
|
||||||
# with your project so that people who use your software can configure
|
|
||||||
# the Makefile on their system.
|
|
||||||
#
|
|
||||||
# In the first line of this file, change the filename
|
|
||||||
# "configure.example.in" to any filename that exists in the top level
|
|
||||||
# directory of your project. This will help configure figure out if
|
|
||||||
# it is processing files in the correct directory.
|
|
||||||
#
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
# Find the compiler and other programs
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
AC_PROG_CC
|
|
||||||
AC_PROG_CPP
|
|
||||||
AC_PROG_RANLIB
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
# Check for OpenStep Foundation library (including libobjects)
|
|
||||||
#
|
|
||||||
# Use these tests if your project relies only on the facilities availible
|
|
||||||
# in the OpenStep Foundation AND you want to be able to compile your
|
|
||||||
# project with either libobjects or any other library that is OpenStep
|
|
||||||
# complient.
|
|
||||||
#
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
AC_CHECK_LIB(Foundation, main, found_foundation=yes, found_foundation=no)
|
|
||||||
if test $found_foundation = yes; then
|
|
||||||
LIBC="$LIBC -lFoundation"
|
|
||||||
fi
|
|
||||||
if test $found_foundation = no; then
|
|
||||||
AC_CHECK_LIB(Foundation_s, main, found_foundation=yes, found_foundation=no)
|
|
||||||
if test $found_foundation = yes; then
|
|
||||||
LIBC="$LIBC -lFoundation_s"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
# Check for OpenStep Foundation library (including libobjects)
|
|
||||||
#
|
|
||||||
# Use this tests to make sure the user has installed libobjects on
|
|
||||||
# their system (also adds -lobjects to the LIBS variable in Makefile).
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
found_objects=no
|
|
||||||
if test $found_foundation = no; then
|
|
||||||
AC_CHECK_LIB(objects, main, found_objects=yes, found_objects=no)
|
|
||||||
fi
|
|
||||||
if test $found_objects = yes; then
|
|
||||||
LIBS="$LIBS -lobjects"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test $found_foundation = no && test $found_objects = no; then
|
|
||||||
AC_MSG_WARN(Cannot find OpenStep Foundation library)
|
|
||||||
echo
|
|
||||||
echo "You need to set LIBS manually in Makefile to point"
|
|
||||||
echo "to the correct location of the Foundation library"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
# Check for OpenStep Foundation kit headers
|
|
||||||
#
|
|
||||||
# These tests also check for not-quite OpenStep complient Foundation
|
|
||||||
# headers such as the ones found in NeXTStep (Release 3.3)
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
AC_CHECK_HEADER(Foundation/NSObject.h, found_objects_h=yes, found_objects_h=no)
|
|
||||||
AC_CHECK_HEADER(foundation/NSObject.h, found_objects_h=yes next_foundation=yes,
|
|
||||||
next_foundation=no)
|
|
||||||
if test $found_objects_h = no; then
|
|
||||||
AC_MSG_WARN(Cannot find OpenStep Foundation headers)
|
|
||||||
echo
|
|
||||||
echo "You need to set CFLAGS manually in Makefile to include "
|
|
||||||
echo "the correct location of the Foundation header directory"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
# Check for other libraries we might need (like the Objective-C runtime
|
|
||||||
# library).
|
|
||||||
#
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
AC_CHECK_LIB(objc, main, found_objc=yes, found_objc=no)
|
|
||||||
if test $found_objc = yes; then
|
|
||||||
LIBS="$LIBS -lobjc -lm"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
# Libraries needed on Solaris (for NSProcessInfo and some other classes)
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
AC_CHECK_LIB(nsl, main)
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
# Check for non-OpenStep Foundation (from NeXT)
|
|
||||||
#
|
|
||||||
# Adds a definition to the DEFS line of the makefile (see the example
|
|
||||||
# Makefile.in) the lets you know if your compiling the program using
|
|
||||||
# the not-quite OpenStep complient NeXT Foundation. Among other things,
|
|
||||||
# this lets you include files from the correct directory, i.e.:
|
|
||||||
#
|
|
||||||
# #ifdef NEXT_FOUNDATION
|
|
||||||
# #include <foundation/NSObject.h>
|
|
||||||
# #else
|
|
||||||
# #include <Foundation/NSObject.h>
|
|
||||||
# #endif
|
|
||||||
#
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
if test $next_foundation = yes; then
|
|
||||||
AC_DEFINE(NEXT_FOUNDATION)
|
|
||||||
AC_DEFINE(NS_BLOCK_ASSERTIONS)
|
|
||||||
CC="cc -traditional-cpp"
|
|
||||||
fi
|
|
||||||
if test $found_objects = yes; then
|
|
||||||
AC_DEFINE(GNU_FOUNDATION)
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
# Setup dynamic linking
|
|
||||||
#
|
|
||||||
# This test uses a custom macro found in the libobjects distribution. If
|
|
||||||
# you plan to use dynamic linking at all, you need to copy the file
|
|
||||||
# libobjects/aclocal.m4 into your project so that autoconf can find it.
|
|
||||||
# Also plan to update the file whenever it changes in libobjects. This
|
|
||||||
# macro sets up quite a few definitions in the Makefile - see the example
|
|
||||||
# makefile for more information.
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
OBJC_SYS_DYNAMIC_FLAGS()
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
# Find the header files
|
|
||||||
#
|
|
||||||
# This is just an example of how you can figure out if certain header
|
|
||||||
# files exist on different systems so you can include them. They are not
|
|
||||||
# necessary for you project if you don't need them.
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
AC_HEADER_STDC
|
|
||||||
AC_CHECK_HEADERS(string.h memory.h unistd.h)
|
|
||||||
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
# Check for some functions
|
|
||||||
#
|
|
||||||
# This is just an example of how you can figure out if certain functions
|
|
||||||
# exist on different systems so you can use them. They are not
|
|
||||||
# necessary for you project if you don't need them.
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
AC_CHECK_FUNCS(getcwd strstr)
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
# Create the makefile
|
|
||||||
#
|
|
||||||
# This creates the Makefile from the Makefile.in file, substituting all
|
|
||||||
# the keywords (between @ pairs) with the proper values determined in
|
|
||||||
# configure.
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
AC_OUTPUT(Makefile.example)
|
|
||||||
|
|
||||||
|
|
58
GNUmakefile
Normal file
58
GNUmakefile
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
#
|
||||||
|
# Main Makefile for GNUstep Base Library.
|
||||||
|
#
|
||||||
|
# Copyright (C) 1997 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# Written by: Scott Christley <scottc@net-community.com>
|
||||||
|
#
|
||||||
|
# This file is part of the GNUstep Base Library.
|
||||||
|
#
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Library General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2 of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Library General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Library General Public
|
||||||
|
# License along with this library; if not, write to the Free
|
||||||
|
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Install into the system root by default
|
||||||
|
GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_SYSTEM_ROOT)
|
||||||
|
|
||||||
|
include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/common.make
|
||||||
|
|
||||||
|
include ./Version
|
||||||
|
|
||||||
|
PACKAGE_NAME = gstep-base
|
||||||
|
|
||||||
|
DIST_FILES = \
|
||||||
|
Makefile Makefile.postamble config.mak.in \
|
||||||
|
configure.in aclocal.m4 acconfig.h \
|
||||||
|
configure.bat INSTALL.WIN32 \
|
||||||
|
config/config.nested.c config/config.nextcc.h config/config.nextrt.m \
|
||||||
|
config/config.vsprintf.c \
|
||||||
|
README.ULTRIX README.ucblib \
|
||||||
|
STATUS RELEASE-NOTES \
|
||||||
|
COPYING COPYING.LIB ChangeLog \
|
||||||
|
configure Version \
|
||||||
|
config.guess mkinstalldirs install-sh config.sub \
|
||||||
|
NSBundle.README \
|
||||||
|
gcc-2.7.2-objc.diff \
|
||||||
|
gcc-2.7.2.1-objc.diff
|
||||||
|
|
||||||
|
#
|
||||||
|
# The list of subproject directories
|
||||||
|
#
|
||||||
|
SUBPROJECTS = Tools src doc checks examples NSCharacterSets NSTimeZones admin
|
||||||
|
|
||||||
|
-include Makefile.preamble
|
||||||
|
|
||||||
|
include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/aggregate.make
|
||||||
|
|
||||||
|
-include Makefile.postamble
|
|
@ -216,6 +216,7 @@ typedef enum _NSStringEncoding
|
||||||
|
|
||||||
#ifndef NO_GNUSTEP
|
#ifndef NO_GNUSTEP
|
||||||
- (const char *) cStringNoCopy;
|
- (const char *) cStringNoCopy;
|
||||||
|
- (const char *) quotedCString;
|
||||||
#endif /* NO_GNUSTEP */
|
#endif /* NO_GNUSTEP */
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -150,6 +150,7 @@ extern NSString *NSHomeDirectoryForUser(NSString * userName);
|
||||||
|
|
||||||
/* Returning the Search List */
|
/* Returning the Search List */
|
||||||
- (NSMutableArray *)searchList;
|
- (NSMutableArray *)searchList;
|
||||||
|
- (void)setSearchList:(NSArray*)newList;
|
||||||
|
|
||||||
/* Maintaining Persistent Domains */
|
/* Maintaining Persistent Domains */
|
||||||
- (NSDictionary *)persistentDomainForName:(NSString *)domainName;
|
- (NSDictionary *)persistentDomainForName:(NSString *)domainName;
|
||||||
|
|
37
Makefile
37
Makefile
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Main Makefile for GNUstep Base Library.
|
# Depreciated Makefile for GNUstep Base Library.
|
||||||
#
|
#
|
||||||
# Copyright (C) 1997 Free Software Foundation, Inc.
|
# Copyright (C) 1997 Free Software Foundation, Inc.
|
||||||
#
|
#
|
||||||
|
@ -22,37 +22,6 @@
|
||||||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
#
|
#
|
||||||
|
|
||||||
# Install into the system root by default
|
all:
|
||||||
GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_SYSTEM_ROOT)
|
@echo You need to use GNU make to compile the GNUstep Base Library
|
||||||
|
|
||||||
include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/common.make
|
|
||||||
|
|
||||||
include ./Version
|
|
||||||
|
|
||||||
PACKAGE_NAME = gstep-base
|
|
||||||
|
|
||||||
DIST_FILES = \
|
|
||||||
Makefile Makefile.postamble config.mak.in \
|
|
||||||
configure.in aclocal.m4 acconfig.h \
|
|
||||||
configure.bat INSTALL.WIN32 \
|
|
||||||
config/config.nested.c config/config.nextcc.h config/config.nextrt.m \
|
|
||||||
config/config.vsprintf.c \
|
|
||||||
README.ULTRIX README.ucblib \
|
|
||||||
STATUS RELEASE-NOTES \
|
|
||||||
COPYING COPYING.LIB ChangeLog \
|
|
||||||
configure Version \
|
|
||||||
config.guess mkinstalldirs install-sh config.sub \
|
|
||||||
NSBundle.README \
|
|
||||||
gcc-2.7.2-objc.diff \
|
|
||||||
gcc-2.7.2.1-objc.diff
|
|
||||||
|
|
||||||
#
|
|
||||||
# The list of subproject directories
|
|
||||||
#
|
|
||||||
SUBPROJECTS = Tools src doc checks examples NSCharacterSets NSTimeZones admin
|
|
||||||
|
|
||||||
-include Makefile.preamble
|
|
||||||
|
|
||||||
include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/aggregate.make
|
|
||||||
|
|
||||||
-include Makefile.postamble
|
|
||||||
|
|
|
@ -15,60 +15,20 @@ without any extension.
|
||||||
The NSBundle class provided with GNUstep Base Library is meant to run
|
The NSBundle class provided with GNUstep Base Library is meant to run
|
||||||
on a variety of systems. However, some set-up is required to use it.
|
on a variety of systems. However, some set-up is required to use it.
|
||||||
Currently it has been tested on only a few systems that support
|
Currently it has been tested on only a few systems that support
|
||||||
dynamic linking -- SunOS, Solaris. It configures for HP, but I
|
dynamic linking -- Linux, SunOS, Solaris. It should work on HP, but I
|
||||||
haven't been able to get it to work yet. There are unconfirmed reports
|
haven't been able to get it to work yet.
|
||||||
it work on Linux systems.
|
|
||||||
|
|
||||||
NSBundle set-up:
|
|
||||||
|
|
||||||
To compile NSBundle into your programs, you need to make sure that the
|
|
||||||
GNUstep Base Library was configured correctly for the dynamic linking
|
|
||||||
system on your machine. This is done automatically in the configure
|
|
||||||
script that comes with the Base Library, but it is possible that the
|
|
||||||
configuration is incorrect for your system (especially if it is not
|
|
||||||
one of the systems listed above). In particular, the Makefile variable
|
|
||||||
DYNAMIC_LINKER is set to link in the proper header file that prvides
|
|
||||||
the dynamic linking for the system.
|
|
||||||
|
|
||||||
You also need to configure your own program to take advantage of
|
|
||||||
NSBundle, and also configure the compilation of any "bundles" you want
|
|
||||||
to link into your program. Most likely you will accomplish this
|
|
||||||
through you own customized configure script. The examples directory
|
|
||||||
contains an example configure.example.in and Makefile.example.in which
|
|
||||||
you can use as a template for configuring your system for compiling so
|
|
||||||
that you can dynamically load object files into your running program.
|
|
||||||
You will need the file aclocal.m4 that comes with the Base Library
|
|
||||||
distribution in order to use configure.example.in in your system.
|
|
||||||
In particular, the example configure script sets the following
|
|
||||||
Makefile variables:
|
|
||||||
|
|
||||||
DYNAMIC_BUNDLER_LINKER - The program that is used to link your bundle so
|
|
||||||
it can be loaded into a running program (e.g. "gcc -Xlinker -r").
|
|
||||||
|
|
||||||
DYNAMIC_LDFLAGS - Flags needed to link the main program so it can
|
|
||||||
accept dynamically loaded bundles.
|
|
||||||
|
|
||||||
DYNAMIC_CFLAGS - Flags needed to compile the sources in the bundle so
|
|
||||||
they can be loaded into the main program (e.g. "-fPIC").
|
|
||||||
|
|
||||||
The configure script also determines which libraries need to be linked
|
|
||||||
in with the main program for the system to perform dynamic linking and
|
|
||||||
adds these to the LIBS variable in Makefile.
|
|
||||||
|
|
||||||
Also, look at the nsbundle program in the checks directory for an
|
|
||||||
example of how to use bundles.
|
|
||||||
|
|
||||||
NSBundle problems:
|
NSBundle problems:
|
||||||
|
|
||||||
As stated previously, NSBundle does not necessarily work on all systems.
|
NSBundle does not necessarily work on all systems. You cannot link in
|
||||||
You cannot link in bundles on systems that do not support dynamic linking,
|
bundles on systems that do not support dynamic linking, although you
|
||||||
although you can use the other facilities of NSBundle, such as locating
|
can use the other facilities of NSBundle, such as locating data files
|
||||||
data files within a bundle.
|
within a bundle.
|
||||||
|
|
||||||
If NSBundle does not work on systems that do support dynamic linking,
|
If NSBundle does not work on systems that do support dynamic linking,
|
||||||
it is likely that the Makefile variable DYNAMIC_BUNDLER_LINKER is not
|
it is likely that the Makefile package has not been configured to make
|
||||||
set-up correctly, or that the GNUstep Base Library did not link in the
|
bundles on your system and/or that the GNUstep Base Library did not
|
||||||
correct header file to use dynamic linking. Diagnosing and fixing
|
link in the correct header file to use dynamic linking. Diagnosing and
|
||||||
these problems is not trivial and requires some knowledge of dynamic
|
fixing these problems is not trivial and requires some knowledge of
|
||||||
linking, object file formats and the Objective-C runtime. Contact Adam
|
dynamic linking, object file formats and the Objective-C
|
||||||
Fedor <fedor@doc.com> for help.
|
runtime. Contact Adam Fedor <fedor@gnu.org> for help.
|
||||||
|
|
|
@ -220,20 +220,24 @@
|
||||||
[desc appendString: @"{"];
|
[desc appendString: @"{"];
|
||||||
if (dict_count > 0)
|
if (dict_count > 0)
|
||||||
[desc appendString: @"\n"];
|
[desc appendString: @"\n"];
|
||||||
|
|
||||||
|
level += 2;
|
||||||
|
|
||||||
while ((key = [keyenum nextObject]))
|
while ((key = [keyenum nextObject]))
|
||||||
{
|
{
|
||||||
NSString *string;
|
NSString *string;
|
||||||
id object;
|
id object;
|
||||||
string = [key description];
|
string = [key description];
|
||||||
|
|
||||||
if ([string rangeOfCharacterFromSet: quotables].length > 0)
|
if ([string rangeOfCharacterFromSet: quotables].length > 0)
|
||||||
[desc appendFormat: @"%*s \"%@\" = ", level, "", string];
|
[desc appendFormat: @"%*s%s = ", level, "", [string quotedCString]];
|
||||||
else
|
else
|
||||||
[desc appendFormat: @"%*s %@ = ", level, "", string];
|
[desc appendFormat: @"%*s%s = ", level, "", [string cStringNoCopy]];
|
||||||
object = [self objectAtKey: key];
|
object = [self objectAtKey: key];
|
||||||
if ([object respondsToSelector: @selector(descriptionWithIndent:)])
|
if ([object respondsToSelector: @selector(descriptionWithIndent:)])
|
||||||
{
|
{
|
||||||
/* This a dictionary or array, so don't quote it */
|
/* This a dictionary or array, so don't quote it */
|
||||||
string = [object descriptionWithIndent: level+2];
|
string = [object descriptionWithIndent: level];
|
||||||
[desc appendFormat: @"%@;\n", string];
|
[desc appendFormat: @"%@;\n", string];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -242,13 +246,15 @@
|
||||||
quote it */
|
quote it */
|
||||||
string = [object description];
|
string = [object description];
|
||||||
if ([string rangeOfCharacterFromSet: quotables].length > 0)
|
if ([string rangeOfCharacterFromSet: quotables].length > 0)
|
||||||
[desc appendFormat: @"\"%@\";\n", string];
|
[desc appendFormat: @"%s;\n", [string quotedCString]];
|
||||||
else
|
else
|
||||||
[desc appendFormat: @"%@;\n", string];
|
[desc appendFormat: @"%s;\n", [string cStringNoCopy]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dict_count == 0)
|
if (dict_count == 0)
|
||||||
level = 0;
|
level = 0;
|
||||||
|
else
|
||||||
|
level -= 2;
|
||||||
[desc appendFormat: @"%*s}", level, ""];
|
[desc appendFormat: @"%*s}", level, ""];
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <Foundation/NSUtilities.h>
|
#include <Foundation/NSUtilities.h>
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
|
#include <Foundation/NSCharacterSet.h>
|
||||||
|
|
||||||
@class NSArrayEnumerator;
|
@class NSArrayEnumerator;
|
||||||
@class NSArrayEnumeratorReverse;
|
@class NSArrayEnumeratorReverse;
|
||||||
|
@ -388,18 +389,59 @@ static Class NSMutableArray_concrete_class;
|
||||||
|
|
||||||
- (NSString*) description
|
- (NSString*) description
|
||||||
{
|
{
|
||||||
|
id string;
|
||||||
id desc;
|
id desc;
|
||||||
|
id object;
|
||||||
int count = [self count];
|
int count = [self count];
|
||||||
int i;
|
int i;
|
||||||
|
NSCharacterSet *quotables;
|
||||||
|
|
||||||
|
quotables = [[NSCharacterSet alphanumericCharacterSet] invertedSet];
|
||||||
|
|
||||||
desc = [NSMutableString stringWithCapacity: 2];
|
desc = [NSMutableString stringWithCapacity: 2];
|
||||||
[desc appendString: @"("];
|
[desc appendString: @"("];
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
[desc appendString: [[self objectAtIndex: 0] description]];
|
{
|
||||||
|
object = [self objectAtIndex: 0];
|
||||||
|
if ([object respondsToSelector: @selector(descriptionWithIndent:)])
|
||||||
|
{
|
||||||
|
/* This a dictionary or array, so don't quote it */
|
||||||
|
string = [object descriptionWithIndent: 0];
|
||||||
|
[desc appendString: string];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* This should be a string or number, so decide if we need to
|
||||||
|
quote it */
|
||||||
|
string = [object description];
|
||||||
|
if ([string rangeOfCharacterFromSet: quotables].length > 0)
|
||||||
|
[desc appendFormat: @"%s", [string quotedCString]];
|
||||||
|
else
|
||||||
|
[desc appendString: string];
|
||||||
|
}
|
||||||
|
}
|
||||||
for (i=1; i<count; i++)
|
for (i=1; i<count; i++)
|
||||||
{
|
{
|
||||||
|
object = [self objectAtIndex: i];
|
||||||
|
|
||||||
[desc appendString: @", "];
|
[desc appendString: @", "];
|
||||||
[desc appendString: [[self objectAtIndex: i] description]];
|
if ([object respondsToSelector: @selector(descriptionWithIndent:)])
|
||||||
|
{
|
||||||
|
/* This a dictionary or array, so don't quote it */
|
||||||
|
string = [object descriptionWithIndent: 0];
|
||||||
|
[desc appendString: string];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* This should be a string or number, so decide if we need to
|
||||||
|
quote it */
|
||||||
|
string = [object description];
|
||||||
|
if ([string rangeOfCharacterFromSet: quotables].length > 0)
|
||||||
|
[desc appendString: [NSString stringWithCString:
|
||||||
|
[string quotedCString]]];
|
||||||
|
else
|
||||||
|
[desc appendString: string];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
[desc appendString: @")"];
|
[desc appendString: @")"];
|
||||||
return desc;
|
return desc;
|
||||||
|
|
|
@ -423,7 +423,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
|
||||||
- (BOOL) writeToFile: (NSString *)path
|
- (BOOL) writeToFile: (NSString *)path
|
||||||
atomically: (BOOL)useAuxiliaryFile
|
atomically: (BOOL)useAuxiliaryFile
|
||||||
{
|
{
|
||||||
const char *theFileName;
|
char *theFileName = NULL;
|
||||||
const char *theRealFileName = NULL;
|
const char *theRealFileName = NULL;
|
||||||
FILE *theFile;
|
FILE *theFile;
|
||||||
int c;
|
int c;
|
||||||
|
@ -443,17 +443,22 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
|
||||||
|
|
||||||
if (useAuxiliaryFile)
|
if (useAuxiliaryFile)
|
||||||
{
|
{
|
||||||
/* FIXME: Is it clear that using the tmpnam() system call is the
|
/* Use the path name of the destination file as a prefix for the
|
||||||
* right way to go? Do we need to worry about renaming the
|
* mktemp() call so that we can be sure that both files are on
|
||||||
* tempfile thus created, if we happen to be moving it across
|
* the same filesystem and the subsequent rename() will work. */
|
||||||
* filesystems, for example? I don't think so. In particular,
|
|
||||||
* I think that this *is* a correct way to handle things. */
|
|
||||||
theFileName = tmpnam(NULL);
|
|
||||||
theRealFileName = [path cString];
|
theRealFileName = [path cString];
|
||||||
|
theFileName = objc_malloc(strlen(theRealFileName) + 7);
|
||||||
|
strcpy(theFileName, theRealFileName);
|
||||||
|
strcat(theFileName, "XXXXXX");
|
||||||
|
if (mktemp(theFileName) == 0)
|
||||||
|
{
|
||||||
|
NSLog(@"mktemp (%s) failed - %s", theFileName, strerror(errno));
|
||||||
|
goto failure;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
theFileName = [path cString];
|
theFileName = (char*)[path cString];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open the file (whether temp or real) for writing. */
|
/* Open the file (whether temp or real) for writing. */
|
||||||
|
@ -504,6 +509,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
|
||||||
NSLog(@"Rename (%s) failed - %s", theFileName, strerror(errno));
|
NSLog(@"Rename (%s) failed - %s", theFileName, strerror(errno));
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
objc_free(theFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* success: */
|
/* success: */
|
||||||
|
@ -511,6 +517,8 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
|
||||||
|
|
||||||
/* Just in case the failure action needs to be changed. */
|
/* Just in case the failure action needs to be changed. */
|
||||||
failure:
|
failure:
|
||||||
|
if (useAuxiliaryFile && theFileName != 0)
|
||||||
|
objc_free(theFileName);
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -315,8 +315,7 @@ static Class NSMutableDictionary_concrete_class;
|
||||||
|
|
||||||
- (BOOL)writeToFile:(NSString *)path atomically:(BOOL)useAuxiliaryFile
|
- (BOOL)writeToFile:(NSString *)path atomically:(BOOL)useAuxiliaryFile
|
||||||
{
|
{
|
||||||
[self notImplemented:_cmd];
|
return [[self description] writeToFile:path atomically:useAuxiliaryFile];
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- copyWithZone: (NSZone*)z
|
- copyWithZone: (NSZone*)z
|
||||||
|
|
|
@ -612,11 +612,14 @@ handle_printf_atsign (FILE *stream,
|
||||||
{
|
{
|
||||||
unsigned len = [self length];
|
unsigned len = [self length];
|
||||||
unichar *s;
|
unichar *s;
|
||||||
|
NSString *tmp;
|
||||||
OBJC_MALLOC(s, unichar, len + [aString length]+1);
|
OBJC_MALLOC(s, unichar, len + [aString length]+1);
|
||||||
[self getCharacters:s];
|
[self getCharacters:s];
|
||||||
[aString getCharacters:s+len];
|
[aString getCharacters:s+len];
|
||||||
s[len + [aString length]]=(unichar) 0;
|
s[len + [aString length]]=(unichar) 0;
|
||||||
return [NSString stringWithCharacters:s length: len + [aString length]];
|
tmp = [NSString stringWithCharacters:s length: len + [aString length]];
|
||||||
|
OBJC_FREE(s);
|
||||||
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dividing Strings into Substrings
|
// Dividing Strings into Substrings
|
||||||
|
@ -2155,6 +2158,72 @@ else
|
||||||
[self subclassResponsibility: _cmd];
|
[self subclassResponsibility: _cmd];
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (const char *) quotedCString
|
||||||
|
{
|
||||||
|
const char *from;
|
||||||
|
char *buf;
|
||||||
|
char *ptr;
|
||||||
|
int len = 0;
|
||||||
|
|
||||||
|
for (from = [self cStringNoCopy]; *from; from++) {
|
||||||
|
switch (*from) {
|
||||||
|
case '\a':
|
||||||
|
case '\b':
|
||||||
|
case '\t':
|
||||||
|
case '\r':
|
||||||
|
case '\n':
|
||||||
|
case '\v':
|
||||||
|
case '\f':
|
||||||
|
case '\\':
|
||||||
|
case '\'' :
|
||||||
|
case '"' :
|
||||||
|
len += 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (isprint(*from) || *from == ' ') {
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
len += 4;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buf = objc_malloc(len + 3);
|
||||||
|
ptr = buf;
|
||||||
|
*ptr++ = '"';
|
||||||
|
for (from = [self cStringNoCopy]; *from; from++) {
|
||||||
|
switch (*from) {
|
||||||
|
case '\a': *ptr++ = '\\'; *ptr++ = 'a'; break;
|
||||||
|
case '\b': *ptr++ = '\\'; *ptr++ = 'b'; break;
|
||||||
|
case '\t': *ptr++ = '\\'; *ptr++ = 't'; break;
|
||||||
|
case '\r': *ptr++ = '\\'; *ptr++ = 'r'; break;
|
||||||
|
case '\n': *ptr++ = '\\'; *ptr++ = 'n'; break;
|
||||||
|
case '\v': *ptr++ = '\\'; *ptr++ = 'v'; break;
|
||||||
|
case '\f': *ptr++ = '\\'; *ptr++ = 'f'; break;
|
||||||
|
case '\\': *ptr++ = '\\'; *ptr++ = '\\'; break;
|
||||||
|
case '\'': *ptr++ = '\\'; *ptr++ = '\''; break;
|
||||||
|
case '"' : *ptr++ = '\\'; *ptr++ = '"'; break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (isprint(*from) || *from == ' ') {
|
||||||
|
*ptr++ = *from;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sprintf(ptr, "\\%03o", *(unsigned char*)from);
|
||||||
|
ptr = &ptr[4];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*ptr++ = '"';
|
||||||
|
*ptr = '\0';
|
||||||
|
[MallocAddress autoreleaseMallocAddress: buf];
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
// #endif /* NO_GNUSTEP */
|
// #endif /* NO_GNUSTEP */
|
||||||
|
|
||||||
|
|
||||||
|
@ -2277,9 +2346,10 @@ else
|
||||||
va_list ap;
|
va_list ap;
|
||||||
id tmp;
|
id tmp;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
tmp = [NSString stringWithFormat:format arguments:ap];
|
tmp = [[NSString alloc] initWithFormat:format arguments:ap];
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
[self appendString:tmp];
|
[self appendString:tmp];
|
||||||
|
[tmp release];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) deleteCharactersInRange: (NSRange)range
|
- (void) deleteCharactersInRange: (NSRange)range
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Implementation for NSUserDefaults for GNUStep
|
/* Implementation for NSUserDefaults for GNUstep
|
||||||
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Written by: Georg Tuparev, EMBL & Academia Naturalis,
|
Written by: Georg Tuparev, EMBL & Academia Naturalis,
|
||||||
|
@ -52,8 +52,8 @@
|
||||||
#define _MAX_COUNT 5 /* Max 10 sec. */
|
#define _MAX_COUNT 5 /* Max 10 sec. */
|
||||||
|
|
||||||
/* User's Defauls database */
|
/* User's Defauls database */
|
||||||
static NSString* GNU_UserDefaultsDatabese = @"./GNUStep/.GNUstepDefaults";
|
static NSString* GNU_UserDefaultsDatabase = @"GNUstep/.GNUstepDefaults";
|
||||||
static NSString* GNU_UserDefaultsDatabeseLock = @"./GNUStep/.GNUstepUDLock";
|
static NSString* GNU_UserDefaultsDatabaseLock = @"GNUstep/.GNUstepUDLock";
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
*** Local method definitions
|
*** Local method definitions
|
||||||
|
@ -165,7 +165,7 @@ static NSMutableString *processName = nil;
|
||||||
[self release]; /* xxx really? -mccallum. */
|
[self release]; /* xxx really? -mccallum. */
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
filename = [userHome stringByAppendingString: GNU_UserDefaultsDatabese];
|
filename = [userHome stringByAppendingString: GNU_UserDefaultsDatabase];
|
||||||
return [self initWithContentsOfFile: filename];
|
return [self initWithContentsOfFile: filename];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,10 +180,12 @@ static NSMutableString *processName = nil;
|
||||||
{
|
{
|
||||||
defaultsDatabase =
|
defaultsDatabase =
|
||||||
[[NSMutableString stringWithFormat:@"%@/%@",
|
[[NSMutableString stringWithFormat:@"%@/%@",
|
||||||
NSUserName(), GNU_UserDefaultsDatabese] retain];
|
NSHomeDirectoryForUser(NSUserName()),
|
||||||
|
GNU_UserDefaultsDatabase] retain];
|
||||||
defaultsDatabaseLock =
|
defaultsDatabaseLock =
|
||||||
[[NSMutableString stringWithFormat:@"%@/%@",
|
[[NSMutableString stringWithFormat:@"%@/%@",
|
||||||
NSUserName(), GNU_UserDefaultsDatabeseLock] retain];
|
NSHomeDirectoryForUser(NSUserName()),
|
||||||
|
GNU_UserDefaultsDatabaseLock] retain];
|
||||||
processName = [[[NSProcessInfo processInfo] processName] retain];
|
processName = [[[NSProcessInfo processInfo] processName] retain];
|
||||||
#if 0
|
#if 0
|
||||||
processName = [[NSMutableString stringWithFormat:@"TestApp"] retain];
|
processName = [[NSMutableString stringWithFormat:@"TestApp"] retain];
|
||||||
|
@ -195,7 +197,12 @@ static NSMutableString *processName = nil;
|
||||||
|
|
||||||
// Initialize persDomains from the archived user defaults (persistent)
|
// Initialize persDomains from the archived user defaults (persistent)
|
||||||
persDomains = [[NSMutableDictionary dictionaryWithCapacity:10] retain];
|
persDomains = [[NSMutableDictionary dictionaryWithCapacity:10] retain];
|
||||||
[self synchronize];
|
if ([self synchronize] == NO)
|
||||||
|
{
|
||||||
|
NSLog(@"unable to load defaults - %s", strerror(errno));
|
||||||
|
[self dealloc];
|
||||||
|
return self = nil;
|
||||||
|
}
|
||||||
|
|
||||||
// Check and if not existent add the Application and the Global domains
|
// Check and if not existent add the Application and the Global domains
|
||||||
if (![persDomains objectForKey:processName])
|
if (![persDomains objectForKey:processName])
|
||||||
|
@ -405,6 +412,12 @@ static NSMutableString *processName = nil;
|
||||||
return searchList;
|
return searchList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setSearchList:(NSArray*)newList
|
||||||
|
{
|
||||||
|
[searchList release];
|
||||||
|
searchList = [newList mutableCopy];
|
||||||
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
*** Maintaining Persistent Domains
|
*** Maintaining Persistent Domains
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
@ -452,18 +465,16 @@ static NSMutableString *processName = nil;
|
||||||
tickingTimer = NO;
|
tickingTimer = NO;
|
||||||
|
|
||||||
// Get file lock
|
// Get file lock
|
||||||
if (mkdir([defaultsDatabase cString],0755) == -1)
|
if (mkdir([defaultsDatabaseLock cString],0755) == -1)
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
// Read the persistent data from the stored database
|
// Read the persistent data from the stored database
|
||||||
newDict = [[NSMutableDictionary allocWithZone:[self zone]]
|
newDict = [[NSMutableDictionary allocWithZone:[self zone]]
|
||||||
initWithContentsOfFile:defaultsDatabase];
|
initWithContentsOfFile:defaultsDatabase];
|
||||||
if (!newDict)
|
if (!newDict)
|
||||||
{
|
newDict = [[NSMutableDictionary allocWithZone:[self zone]]
|
||||||
rmdir([defaultsDatabaseLock cString]); // release file lock
|
initWithCapacity:1];
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changedDomains)
|
if (changedDomains)
|
||||||
{ // Synchronize bpth dictionaries
|
{ // Synchronize bpth dictionaries
|
||||||
NSEnumerator *enumerator = [changedDomains objectEnumerator];
|
NSEnumerator *enumerator = [changedDomains objectEnumerator];
|
||||||
|
|
|
@ -26,10 +26,13 @@ GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_SYSTEM_ROOT)
|
||||||
include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/common.make
|
include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/common.make
|
||||||
|
|
||||||
# The application to be compiled
|
# The application to be compiled
|
||||||
OBJC_PROGRAM_NAME = gdomap
|
OBJC_PROGRAM_NAME = gdomap dread dwrite dremove
|
||||||
|
|
||||||
# The source files to be compiled
|
# The source files to be compiled
|
||||||
gdomap_C_FILES = gdomap.c
|
gdomap_C_FILES = gdomap.c
|
||||||
|
dread_C_FILES = dread.c
|
||||||
|
dremove_C_FILES = dremove.c
|
||||||
|
dwrite_C_FILES = dwrite.c
|
||||||
|
|
||||||
-include Makefile.preamble
|
-include Makefile.preamble
|
||||||
|
|
130
Tools/dread.m
Normal file
130
Tools/dread.m
Normal file
|
@ -0,0 +1,130 @@
|
||||||
|
/* This is a simple tool to read and display defaults information
|
||||||
|
Copyright (C) 1997 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Written by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
Created: October 1997
|
||||||
|
|
||||||
|
This file is part of the GNUstep Base Library.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Foundation/NSArray.h>
|
||||||
|
#include <Foundation/NSDictionary.h>
|
||||||
|
#include <Foundation/NSString.h>
|
||||||
|
#include <Foundation/NSProcessInfo.h>
|
||||||
|
#include <Foundation/NSUserDefaults.h>
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
NSUserDefaults *defs;
|
||||||
|
NSProcessInfo *proc;
|
||||||
|
NSArray *args;
|
||||||
|
NSArray *domains;
|
||||||
|
NSString *owner;
|
||||||
|
NSString *name;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
[NSObject enableDoubleReleaseCheck: YES];
|
||||||
|
|
||||||
|
proc = [NSProcessInfo processInfo];
|
||||||
|
if (proc == nil) {
|
||||||
|
NSLog(@"unable to get process information!\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
defs = [NSUserDefaults standardUserDefaults];
|
||||||
|
if (defs == nil) {
|
||||||
|
NSLog(@"unable to access defaults database!\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
args = [proc arguments];
|
||||||
|
if ([args count] == 0) {
|
||||||
|
NSLog(@"no arguments supplied!\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([[args objectAtIndex: 0] isEqual: @"-g"]) {
|
||||||
|
owner = NSGlobalDomain;
|
||||||
|
name = [args objectAtIndex: 1];
|
||||||
|
}
|
||||||
|
else if ([[args objectAtIndex: 0] isEqual: @"-l"]) {
|
||||||
|
owner = nil;
|
||||||
|
name = nil;
|
||||||
|
}
|
||||||
|
else if ([[args objectAtIndex: 0] isEqual: @"-n"]) {
|
||||||
|
owner = NSGlobalDomain;
|
||||||
|
name = [args objectAtIndex: 1];
|
||||||
|
}
|
||||||
|
else if ([[args objectAtIndex: 0] isEqual: @"-o"]) {
|
||||||
|
owner = [args objectAtIndex: 1];
|
||||||
|
name = nil;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ([args count] > 1) {
|
||||||
|
owner = [args objectAtIndex: 0];
|
||||||
|
name = [args objectAtIndex: 1];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
owner = NSGlobalDomain;
|
||||||
|
name = [args objectAtIndex: 0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
domains = [defs persistentDomainNames];
|
||||||
|
for (i = 0; i < [domains count]; i++) {
|
||||||
|
NSString *domainName = [domains objectAtIndex: i];
|
||||||
|
|
||||||
|
if (owner == nil || [owner isEqual: domainName]) {
|
||||||
|
NSDictionary *dom;
|
||||||
|
|
||||||
|
dom = [defs persistentDomainForName: domainName];
|
||||||
|
if (dom) {
|
||||||
|
if (name == nil) {
|
||||||
|
NSEnumerator *enumerator;
|
||||||
|
NSString *key;
|
||||||
|
|
||||||
|
enumerator = [dom keyEnumerator];
|
||||||
|
while ((key = [enumerator nextObject]) != nil) {
|
||||||
|
id obj = [dom objectForKey: key];
|
||||||
|
|
||||||
|
printf("%s %s %s\n",
|
||||||
|
[domainName cString], [key cString],
|
||||||
|
[[obj description] cString]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
id obj = [dom objectForKey: name];
|
||||||
|
|
||||||
|
if (obj) {
|
||||||
|
printf("%s %s %s\n",
|
||||||
|
[domainName cString], [name cString],
|
||||||
|
[[obj description] cString]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("dread: couldn't read default\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
175
Tools/dremove.m
Normal file
175
Tools/dremove.m
Normal file
|
@ -0,0 +1,175 @@
|
||||||
|
/* This is a simple tool to remove defaults information
|
||||||
|
Copyright (C) 1997 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Written by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
Created: October 1997
|
||||||
|
|
||||||
|
This file is part of the GNUstep Base Library.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Foundation/NSArray.h>
|
||||||
|
#include <Foundation/NSDictionary.h>
|
||||||
|
#include <Foundation/NSString.h>
|
||||||
|
#include <Foundation/NSProcessInfo.h>
|
||||||
|
#include <Foundation/NSUserDefaults.h>
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
NSUserDefaults *defs;
|
||||||
|
NSProcessInfo *proc;
|
||||||
|
NSArray *args;
|
||||||
|
NSMutableDictionary *domain;
|
||||||
|
NSString *owner;
|
||||||
|
NSString *name;
|
||||||
|
|
||||||
|
[NSObject enableDoubleReleaseCheck: YES];
|
||||||
|
|
||||||
|
proc = [NSProcessInfo processInfo];
|
||||||
|
if (proc == nil) {
|
||||||
|
NSLog(@"unable to get process information!\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
defs = [NSUserDefaults standardUserDefaults];
|
||||||
|
if (defs == nil) {
|
||||||
|
NSLog(@"unable to access defaults database!\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
args = [proc arguments];
|
||||||
|
if ([args count] == 0) {
|
||||||
|
char buf[BUFSIZ*10];
|
||||||
|
|
||||||
|
while (fgets(buf, sizeof(buf), stdin) != 0) {
|
||||||
|
char *ptr;
|
||||||
|
char *start;
|
||||||
|
|
||||||
|
start = buf;
|
||||||
|
|
||||||
|
if (*start == '"') {
|
||||||
|
for (ptr = ++start; *ptr; ptr++) {
|
||||||
|
if (*ptr == '\\' && ptr[1] != '\0') {
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
else if (*ptr == '"') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ptr = start;
|
||||||
|
while (*ptr && !isspace(*ptr)) {
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (*ptr) {
|
||||||
|
*ptr++ = '\0';
|
||||||
|
}
|
||||||
|
while (isspace(*ptr)) {
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
if (*start == '\0') {
|
||||||
|
printf("dremove: invalid input\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
owner = [NSString stringWithCString: start];
|
||||||
|
start = ptr;
|
||||||
|
|
||||||
|
if (*start == '"') {
|
||||||
|
for (ptr = ++start; *ptr; ptr++) {
|
||||||
|
if (*ptr == '\\' && ptr[1] != '\0') {
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
else if (*ptr == '"') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ptr = start;
|
||||||
|
while (*ptr && !isspace(*ptr)) {
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (*ptr) {
|
||||||
|
*ptr++ = '\0';
|
||||||
|
}
|
||||||
|
while (isspace(*ptr)) {
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
if (*start == '\0') {
|
||||||
|
printf("dremove: invalid input\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
name = [NSString stringWithCString: start];
|
||||||
|
domain = [[defs persistentDomainForName: owner] mutableCopy];
|
||||||
|
if (domain == nil || [domain objectForKey: name] == nil) {
|
||||||
|
printf("dremoveL couldn't remove %s owned by %s\n",
|
||||||
|
[name quotedCString], [owner quotedCString]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
[domain removeObjectForKey: name];
|
||||||
|
[defs setPersistentDomain: domain forName: owner];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ([[args objectAtIndex: 0] isEqual: @"-g"]) {
|
||||||
|
owner = NSGlobalDomain;
|
||||||
|
name = [args objectAtIndex: 1];
|
||||||
|
domain = [[defs persistentDomainForName: owner] mutableCopy];
|
||||||
|
if (domain == nil || [domain objectForKey: name] == nil) {
|
||||||
|
printf("dremoveL couldn't remove %s owned by %s\n",
|
||||||
|
[name quotedCString], [owner quotedCString]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
[domain removeObjectForKey: name];
|
||||||
|
[defs setPersistentDomain: domain forName: owner];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ([args count] > 1) {
|
||||||
|
owner = [args objectAtIndex: 0];
|
||||||
|
name = [args objectAtIndex: 1];
|
||||||
|
domain = [[defs persistentDomainForName: owner] mutableCopy];
|
||||||
|
if (domain == nil || [domain objectForKey: name] == nil) {
|
||||||
|
printf("dremoveL couldn't remove %s owned by %s\n",
|
||||||
|
[name quotedCString], [owner quotedCString]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
[domain removeObjectForKey: name];
|
||||||
|
[defs setPersistentDomain: domain forName: owner];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
NSLog(@"got app name '%s' but no variable name.\n",
|
||||||
|
[[args objectAtIndex: 0] cString]);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We don't want dremove in the defaults database - so remove it. */
|
||||||
|
[defs removePersistentDomainForName: [proc processName]];
|
||||||
|
if ([defs synchronize] == NO) {
|
||||||
|
NSLog(@"unable to write to defaults database - %s\n", strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
240
Tools/dwrite.m
Normal file
240
Tools/dwrite.m
Normal file
|
@ -0,0 +1,240 @@
|
||||||
|
/* This is a simple tool to write defaults information to the database
|
||||||
|
Copyright (C) 1997 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Written by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
Created: October 1997
|
||||||
|
|
||||||
|
This file is part of the GNUstep Base Library.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Foundation/NSArray.h>
|
||||||
|
#include <Foundation/NSDictionary.h>
|
||||||
|
#include <Foundation/NSString.h>
|
||||||
|
#include <Foundation/NSProcessInfo.h>
|
||||||
|
#include <Foundation/NSUserDefaults.h>
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
NSUserDefaults *defs;
|
||||||
|
NSProcessInfo *proc;
|
||||||
|
NSArray *args;
|
||||||
|
NSMutableDictionary *domain;
|
||||||
|
NSString *owner;
|
||||||
|
NSString *name;
|
||||||
|
NSString *value;
|
||||||
|
const char *text;
|
||||||
|
id obj;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
[NSObject enableDoubleReleaseCheck: YES];
|
||||||
|
|
||||||
|
proc = [NSProcessInfo processInfo];
|
||||||
|
if (proc == nil) {
|
||||||
|
NSLog(@"unable to get process information!\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
defs = [NSUserDefaults standardUserDefaults];
|
||||||
|
if (defs == nil) {
|
||||||
|
NSLog(@"unable to access defaults database!\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
args = [proc arguments];
|
||||||
|
if ([args count] == 0) {
|
||||||
|
char buf[BUFSIZ*10];
|
||||||
|
|
||||||
|
while (fgets(buf, sizeof(buf), stdin) != 0) {
|
||||||
|
char *ptr;
|
||||||
|
char *start;
|
||||||
|
|
||||||
|
obj = nil;
|
||||||
|
start = buf;
|
||||||
|
|
||||||
|
if (*start == '"') {
|
||||||
|
for (ptr = ++start; *ptr; ptr++) {
|
||||||
|
if (*ptr == '\\' && ptr[1] != '\0') {
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
else if (*ptr == '"') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ptr = start;
|
||||||
|
while (*ptr && !isspace(*ptr)) {
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (*ptr) {
|
||||||
|
*ptr++ = '\0';
|
||||||
|
}
|
||||||
|
while (isspace(*ptr)) {
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
if (*start == '\0') {
|
||||||
|
printf("dwrite: invalid input\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
owner = [NSString stringWithCString: start];
|
||||||
|
start = ptr;
|
||||||
|
|
||||||
|
if (*start == '"') {
|
||||||
|
for (ptr = ++start; *ptr; ptr++) {
|
||||||
|
if (*ptr == '\\' && ptr[1] != '\0') {
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
else if (*ptr == '"') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ptr = start;
|
||||||
|
while (*ptr && !isspace(*ptr)) {
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (*ptr) {
|
||||||
|
*ptr++ = '\0';
|
||||||
|
}
|
||||||
|
while (isspace(*ptr)) {
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
if (*start == '\0') {
|
||||||
|
printf("dwrite: invalid input\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
name = [NSString stringWithCString: start];
|
||||||
|
start = ptr;
|
||||||
|
|
||||||
|
if (*start == '(' || *start == '{' || *start == '<') {
|
||||||
|
ptr = &start[strlen(start)-1];
|
||||||
|
while (isspace(*ptr)) {
|
||||||
|
*ptr-- = '\0';
|
||||||
|
}
|
||||||
|
value = [NSString stringWithCString: start];
|
||||||
|
while ((obj = [value propertyList]) == nil) {
|
||||||
|
if (fgets(buf, sizeof(buf), stdin) != 0) {
|
||||||
|
ptr = &buf[strlen(buf)-1];
|
||||||
|
while (isspace(*ptr)) {
|
||||||
|
*ptr-- = '\0';
|
||||||
|
}
|
||||||
|
value = [value stringByAppendingString: @"\n"];
|
||||||
|
value = [value stringByAppendingString:
|
||||||
|
[NSString stringWithCString: buf]];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("dwrite: invalid input\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (*start == '"') {
|
||||||
|
for (ptr = ++start; *ptr; ptr++) {
|
||||||
|
if (*ptr == '\\' && ptr[1] != '\0') {
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
else if (*ptr == '"') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ptr = start;
|
||||||
|
while (*ptr && !isspace(*ptr)) {
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (obj == nil) {
|
||||||
|
if (*ptr) {
|
||||||
|
*ptr++ = '\0';
|
||||||
|
}
|
||||||
|
if (*start == '\0') {
|
||||||
|
printf("dwrite: invalid input\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
obj = [NSString stringWithCString: start];
|
||||||
|
}
|
||||||
|
domain = [[defs persistentDomainForName: owner] mutableCopy];
|
||||||
|
if (domain == nil) {
|
||||||
|
domain = [NSMutableDictionary dictionaryWithCapacity:1];
|
||||||
|
}
|
||||||
|
[domain setObject: obj forKey: name];
|
||||||
|
[defs setPersistentDomain: domain forName: owner];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ([[args objectAtIndex: 0] isEqual: @"-g"]) {
|
||||||
|
if ([args count] > 2) {
|
||||||
|
owner = NSGlobalDomain;
|
||||||
|
name = [args objectAtIndex: 1];
|
||||||
|
value = [args objectAtIndex: 2];
|
||||||
|
text = [value cStringNoCopy];
|
||||||
|
if (*text == '(' || *text == '{' || *text == '<') {
|
||||||
|
obj = [value propertyList];
|
||||||
|
}
|
||||||
|
if (obj == nil) {
|
||||||
|
obj = value;
|
||||||
|
}
|
||||||
|
domain = [[defs persistentDomainForName: owner] mutableCopy];
|
||||||
|
if (domain == nil) {
|
||||||
|
domain = [NSMutableDictionary dictionaryWithCapacity:1];
|
||||||
|
}
|
||||||
|
[domain setObject: obj forKey: name];
|
||||||
|
[defs setPersistentDomain: domain forName: owner];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
NSLog(@"too few arguments supplied!\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ([args count] > 2) {
|
||||||
|
owner = [args objectAtIndex: 0];
|
||||||
|
name = [args objectAtIndex: 1];
|
||||||
|
value = [args objectAtIndex: 2];
|
||||||
|
text = [value cStringNoCopy];
|
||||||
|
if (*text == '(' || *text == '{' || *text == '<') {
|
||||||
|
obj = [value propertyList];
|
||||||
|
}
|
||||||
|
if (obj == nil) {
|
||||||
|
obj = value;
|
||||||
|
}
|
||||||
|
domain = [[defs persistentDomainForName: owner] mutableCopy];
|
||||||
|
if (domain == nil) {
|
||||||
|
domain = [NSMutableDictionary dictionaryWithCapacity:1];
|
||||||
|
}
|
||||||
|
[domain setObject: obj forKey: name];
|
||||||
|
[defs setPersistentDomain: domain forName: owner];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
NSLog(@"too few arguments supplied!\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We don't want dwrite in the defaults database - so remove it. */
|
||||||
|
[defs removePersistentDomainForName: [proc processName]];
|
||||||
|
[defs synchronize];
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue