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:
Adam Fedor 1997-10-31 16:26:44 +00:00
parent a992701d88
commit cc19486e18
26 changed files with 867 additions and 411 deletions

View file

@ -26,10 +26,13 @@ GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_SYSTEM_ROOT)
include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/common.make
# The application to be compiled
OBJC_PROGRAM_NAME = gdomap
OBJC_PROGRAM_NAME = gdomap dread dwrite dremove
# The source files to be compiled
gdomap_C_FILES = gdomap.c
dread_C_FILES = dread.c
dremove_C_FILES = dremove.c
dwrite_C_FILES = dwrite.c
-include Makefile.preamble

130
Tools/dread.m Normal file
View 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
View 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
View 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);
}