From: Gerfried Fuchs Date: Tue, 17 Apr 2012 12:19:00 +0000 (+0200) Subject: Apply branch 'experimental' to master X-Git-Tag: debian/0.6.0_pre2-2~3 X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=6f33a81fa948039f42f38cb96f736820be524539;hp=cb2e07351834ad17b2bb0b8668e13466e1058ca1;p=pkg%2Fabook.git Apply branch 'experimental' to master --- diff --git a/ANNOUNCE b/ANNOUNCE index abff6e6..26f691f 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,4 +1,4 @@ -abook v 0.5 +abook Abook is small and powerful addressbook program designed to use with mutt mail client. Abook runs on Linux / FreeBSD and probably with small changes on other diff --git a/AUTHORS b/AUTHORS index 1d2df30..9570e77 100644 --- a/AUTHORS +++ b/AUTHORS @@ -4,6 +4,7 @@ abook AUTHORS Jaakko Heinonen Cedric Duval + - views - i18n - etc. @@ -24,3 +25,4 @@ Koenraad Heijlen - csv import filter - palmcsv export filter - fixes + diff --git a/BUGS b/BUGS index b1164c6..5e2fcbe 100644 --- a/BUGS +++ b/BUGS @@ -10,13 +10,18 @@ known bugs in abook ftp://ftp.gnu.org/gnu/readline/readline-4.3-patches/readline43-001 * cursor disappears in some cases with abook_readline() on Solaris. If - you have problems it is recommended to use the ncurses library + you have problems it is recommended to use the GNU ncurses library * terminal state is not restored correctly on exit with certain ncurses and readline combination (more information is needed on this) * file format is not tolerant for character set changes +* datafile is always removed and rewritten from scratch (symlinks don't work, + timestamp is always updated, comments are removed) + +* comma (,) is not allowed in lists and is converted to _ + -- [25] name=Lastname, Firstname @@ -39,4 +44,4 @@ Filters: * fseek in ldif import filter should be eliminated -$Id: BUGS,v 1.16.2.1 2006/02/23 13:39:13 jheinonen Exp $ +$Id: BUGS,v 1.18 2006/08/24 09:46:08 jheinonen Exp $ diff --git a/ChangeLog b/ChangeLog index 2f96df3..967f96a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,13 +1,24 @@ +0.6.0 + - configurable views (Cedric Duval) + - new field types, lists and improved custom field support (Cedric Duval) + - index_format option (Cedric Duval) + - Italian translation (Claudio Stazzone) + - BSD calendar export filter (Guillem Jover) + - translation updates + - bugfixes + 0.5.6 - translation fixes - fixed gcrd export format (\r\n line endings according to RFC, Marc Tardif) - fix localized keybindings with --disable-nls 0.5.5 + - fixed gcrd export format (Marc Tardif) - i18n support (Cedric Duval) - French translation (Cedric Duval) - Swedish translation (Susanna Björverud) - Japanese translation (Takahashi Tamotsu) + - German translation (Johannes Weißl) - palmcsv import filter (Marc Tardif) - use better common code for csv filters (Marc Tardif) - translation HOWTO (Cedric Duval) diff --git a/Makefile.am b/Makefile.am index 304d608..1b3d27e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,20 +1,22 @@ bin_PROGRAMS = abook -abook_SOURCES = abook.c database.c filter.c list.c misc.c \ - options.c edit.c ldif.c ui.c getname.c \ - getopt.c getopt1.c gettext.c abook_rl.c mbswidth.c \ - xmalloc.c \ - abook.h database.h filter.h list.h misc.h help.h \ - options.h edit.h ldif.h abook_curses.h ui.h getname.h \ - getopt.h gettext.h abook_rl.h mbswidth.h \ - xmalloc.h +abook_SOURCES = abook.c abook_rl.c database.c edit.c \ + filter.c getname.c getopt.c getopt1.c gettext.c \ + ldif.c list.c mbswidth.c misc.c options.c \ + ui.c views.c xmalloc.c \ + \ + abook.h abook_curses.h abook_rl.h database.h edit.h \ + filter.h getname.h getopt.h gettext.h \ + help.h list.h ldif.h mbswidth.h misc.h options.h \ + ui.h views.h xmalloc.h EXTRA_DIST = config.rpath ANNOUNCE BUGS FAQ abook.1 abookrc.5 sample.abookrc \ - abook.spec contrib doc/HOWTO.translating_abook + abook.spec contrib doc/HOWTO.translating_abook RELEASE_NOTES abook_LDADD = @LIBINTL@ + install-data-local: $(mkinstalldirs) $(DESTDIR)$(mandir)/man1 $(DESTDIR)$(mandir)/man5 $(INSTALL_DATA) $(srcdir)/abook.1 $(DESTDIR)$(mandir)/man1/ diff --git a/Makefile.in b/Makefile.in index 83d73ed..1f1d6db 100644 --- a/Makefile.in +++ b/Makefile.in @@ -73,11 +73,12 @@ CONFIG_CLEAN_FILES = abook.spec intl/Makefile am__installdirs = "$(DESTDIR)$(bindir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) -am_abook_OBJECTS = abook.$(OBJEXT) database.$(OBJEXT) filter.$(OBJEXT) \ - list.$(OBJEXT) misc.$(OBJEXT) options.$(OBJEXT) edit.$(OBJEXT) \ - ldif.$(OBJEXT) ui.$(OBJEXT) getname.$(OBJEXT) getopt.$(OBJEXT) \ - getopt1.$(OBJEXT) gettext.$(OBJEXT) abook_rl.$(OBJEXT) \ - mbswidth.$(OBJEXT) xmalloc.$(OBJEXT) +am_abook_OBJECTS = abook.$(OBJEXT) abook_rl.$(OBJEXT) \ + database.$(OBJEXT) edit.$(OBJEXT) filter.$(OBJEXT) \ + getname.$(OBJEXT) getopt.$(OBJEXT) getopt1.$(OBJEXT) \ + gettext.$(OBJEXT) ldif.$(OBJEXT) list.$(OBJEXT) \ + mbswidth.$(OBJEXT) misc.$(OBJEXT) options.$(OBJEXT) \ + ui.$(OBJEXT) views.$(OBJEXT) xmalloc.$(OBJEXT) abook_OBJECTS = $(am_abook_OBJECTS) abook_DEPENDENCIES = DEFAULT_INCLUDES = -I. -I$(srcdir) -I. @@ -223,17 +224,18 @@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ -abook_SOURCES = abook.c database.c filter.c list.c misc.c \ - options.c edit.c ldif.c ui.c getname.c \ - getopt.c getopt1.c gettext.c abook_rl.c mbswidth.c \ - xmalloc.c \ - abook.h database.h filter.h list.h misc.h help.h \ - options.h edit.h ldif.h abook_curses.h ui.h getname.h \ - getopt.h gettext.h abook_rl.h mbswidth.h \ - xmalloc.h +abook_SOURCES = abook.c abook_rl.c database.c edit.c \ + filter.c getname.c getopt.c getopt1.c gettext.c \ + ldif.c list.c mbswidth.c misc.c options.c \ + ui.c views.c xmalloc.c \ + \ + abook.h abook_curses.h abook_rl.h database.h edit.h \ + filter.h getname.h getopt.h gettext.h \ + help.h list.h ldif.h mbswidth.h misc.h options.h \ + ui.h views.h xmalloc.h EXTRA_DIST = config.rpath ANNOUNCE BUGS FAQ abook.1 abookrc.5 sample.abookrc \ - abook.spec contrib doc/HOWTO.translating_abook + abook.spec contrib doc/HOWTO.translating_abook RELEASE_NOTES abook_LDADD = @LIBINTL@ SUBDIRS = intl po @@ -346,6 +348,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/views.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmalloc.Po@am__quote@ .c.o: diff --git a/README b/README index 83bc73d..ad56f59 100644 --- a/README +++ b/README @@ -6,7 +6,7 @@ Abook is an addressbook program with mutt mail client support. COMPILATION -To compile abook you must have ncurses developement libraries installed. +To compile abook you must have ncurses development libraries installed. Starting from version 0.4.10 abook is known to compile with the native curses library of SUN Solaris and OpenBSD. Since version 0.5.0 GNU readline is required. Please note that other readline implementations don't work. @@ -16,8 +16,8 @@ to somewhere. (for example abook 2> debug or abook 2> /dev/null) Abook has been compiled and tested successfully on following platforms: (NOTE: All versions of abook haven't been tested on all platforms.) -Linux (Debian GNU/Linux, RedHat Linux, all other distributions with GNU ncurses - and GNU readline should work) +Linux (distributions with moderately new GNU ncurses and GNU readline libraries + should work) Darwin Solaris FreeBSD @@ -43,9 +43,13 @@ After this you can make queries from mutt using the query command ('Q') and add sender e-mail addresses to the addressbook from pager using 'A' command. (Of course you can choose another keybinding if you like.) -It's also recommeded to set pipe_decode variable in mutt configuration. +It's also recommended to set pipe_decode variable in mutt configuration. See the mutt manual for details. +UPGRADING FROM VERSION 0.5 + +See RELEASE_NOTES . + UPGRADING FROM VERSION 0.4 You must import your abook 0.4 addressbook file because it is stored @@ -70,8 +74,8 @@ LICENSE All files in this distribution are released under GNU GENERAL PUBLIC LICENSE. See COPYING for details. -CONTACT AUTHOR +CONTACT AUTHORS -Send bugreports, fixes, wishes etc. to Jaakko Heinonen - or use the mailing list. +Send bugreports, fixes, wishes etc. to abook mailing list: +https://lists.sourceforge.net/lists/listinfo/abook-devel diff --git a/RELEASE_NOTES b/RELEASE_NOTES new file mode 100644 index 0000000..92fcca6 --- /dev/null +++ b/RELEASE_NOTES @@ -0,0 +1,32 @@ +This file lists major changes affecting abook's behavior. +Please read this file carefully when upgrading abook. +A more comprehensive list of changes can be found in the ChangeLog file. + +-- + +0.6.0pre2: + * The four following configuration options have been deprecated and will + no longer be accepted by abook: + * emailpos + * extra_column + * extra_alternative + * extrapos + + They have been replaced with a single more flexible option: + index_format. + + This option is a string defining the format of a line in the main list. + It allows displaying of as many fields as desired, with optional + width limit, as well as an arbitrary number of alternative fields. + +0.6.0pre1 (2006-08-30): + * The 'customfield' command has been obsoleted by a more flexible set + of commands: 'field' and 'view'. + + Those two commands make it possible to define fields and organize + them within tabs as you see fit. + + Not using these commands, the look and feel of previous releases + will mostly be kept the same. Also see the related 'preserve_fields' + configuration variable. + diff --git a/THANKS b/THANKS index 490f4e6..ba96d26 100644 --- a/THANKS +++ b/THANKS @@ -19,5 +19,8 @@ Jeff Covey Giuseppe Corbelli Mariusz Balewski Marc Tardif +Gerfried Fuchs +Josef Schugt +Guillem Jover See also AUTHORS diff --git a/TODO b/TODO index deda7c3..488a5a3 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,7 @@ +0.6 + - allcsv should export all fields + +generic: - grouping - new file format (xml?) - custom views, keybindings diff --git a/abook.1 b/abook.1 index 452f0a6..bb7ed4e 100644 --- a/abook.1 +++ b/abook.1 @@ -1,4 +1,4 @@ -.TH ABOOK 1 "June 6, 2003" +.TH ABOOK 1 2006-09-06 .nh .SH NAME abook \- text-based address book program @@ -79,6 +79,8 @@ The following \fIoutputformats\fR are supported: - \fBspruce\fP Spruce address book .br - \fBwl\fP Wanderlust address book +.br +- \fBbsdcal\fP BSD calendar .TP \fB\-\-add-email\fP Read an e-mail message from stdin and add the sender to the addressbook. diff --git a/abook.c b/abook.c index 1b8c0da..f20c45d 100644 --- a/abook.c +++ b/abook.c @@ -1,5 +1,5 @@ /* - * $Id: abook.c,v 1.57 2005/10/05 11:03:36 jheinonen Exp $ + * $Id: abook.c,v 1.60 2006/09/04 18:29:24 cduval Exp $ * * by JH * @@ -33,6 +33,7 @@ #include "options.h" #include "getname.h" #include "getopt.h" +#include "views.h" #include "xmalloc.h" static void init_abook(); @@ -52,6 +53,7 @@ static char *rcfile = NULL; bool alternative_datafile = FALSE; bool alternative_rcfile = FALSE; + static int datafile_writeable() { @@ -126,9 +128,12 @@ init_abook() printf(_("Press enter to continue...\n")); fgetc(stdin); } + init_default_views(); signal(SIGTERM, quit_abook_sig); + init_index(); + if(init_ui()) exit(EXIT_FAILURE); @@ -190,6 +195,8 @@ main(int argc, char **argv) xmalloc_set_error_handler(xmalloc_error_handler); + prepare_database_internals(); + parse_command_line(argc, argv); init_abook(); @@ -375,7 +382,7 @@ parse_command_line(int argc, char **argv) } } - if (optind < argc) { + if(optind < argc) { fprintf(stderr, _("%s: unrecognized arguments on command line\n"), argv[0]); exit(EXIT_FAILURE); @@ -427,7 +434,6 @@ show_usage() * end of CLI */ -extern list_item *database; static void quit_mutt_query(int status) @@ -441,19 +447,20 @@ quit_mutt_query(int status) static void muttq_print_item(FILE *file, int item) { - char emails[MAX_EMAILS][MAX_EMAIL_LEN]; - int i; - - split_emailstr(item, emails); - - for(i = 0; i < (opt_get_bool(BOOL_MUTT_RETURN_ALL_EMAILS) ? - MAX_EMAILS : 1) ; i++) - if( *emails[i] ) - fprintf(file, "%s\t%s\t%s\n", emails[i], - database[item][NAME], - database[item][NOTES] == NULL ? " " : - database[item][NOTES] + abook_list *emails, *e; + char *tmp = db_email_get(item); + + emails = csv_to_abook_list(tmp); + free(tmp); + + for(e = emails; e; e = e->next) { + fprintf(file, "%s\t%s\t%s\n", e->data, db_name_get(item), + !db_fget(item, NOTES) ?" " :db_fget(item, NOTES) ); + if(!opt_get_bool(BOOL_MUTT_RETURN_ALL_EMAILS)) + break; + } + abook_list_free(&emails); } static void @@ -503,11 +510,11 @@ make_mailstr(int item) { char email[MAX_EMAIL_LEN]; char *ret; - char *name = strdup_printf("\"%s\"", database[item][NAME]); + char *name = strdup_printf("\"%s\"", db_name_get(item)); get_first_email(email, item); - ret = *database[item][EMAIL] ? + ret = *email ? strdup_printf("%s <%s>", name, email) : xstrdup(name); @@ -577,10 +584,10 @@ launch_wwwbrowser(int item) if( !is_valid_item(item) ) return; - if( database[item][URL] ) + if(db_fget(item, URL)) cmd = strdup_printf("%s '%s'", opt_get_str(STR_WWW_COMMAND), - safe_str(database[item][URL])); + safe_str(db_fget(item, URL))); else return; @@ -632,6 +639,7 @@ convert(char *srcformat, char *srcfile, char *dstformat, char *dstfile) set_filenames(); init_opts(); load_opts(rcfile); + init_standard_fields(); switch(import_file(srcformat, srcfile)) { case -1: @@ -752,10 +760,11 @@ add_email_add_item(int quiet, char *name, char *email) fclose(in); } - memset(item, 0, sizeof(item)); - item[NAME] = xstrdup(name); - item[EMAIL] = xstrdup(email); + item = item_create(); + item_fput(item, NAME, xstrdup(name)); + item_fput(item, EMAIL, xstrdup(email)); add_item2database(item); + item_free(&item); return 1; } diff --git a/abook.h b/abook.h index 564caf3..fc6c1bb 100644 --- a/abook.h +++ b/abook.h @@ -49,6 +49,8 @@ int strncasecmp (const char *, const char *, size_t); #define ISSPACE(c) isspace((unsigned char)c) +#define SKIPWS(c) while(*(c) && ISSPACE(*(c))) c++ + #ifndef DEBUG # define NDEBUG 1 #else diff --git a/abook.spec b/abook.spec index 48ce4b4..2b8023b 100644 --- a/abook.spec +++ b/abook.spec @@ -1,6 +1,6 @@ Summary: Text-based addressbook program Name: abook -Version: 0.5.6 +Version: 0.6.0pre2 Release: 1 License: GPL Group: Utilities diff --git a/abookrc.5 b/abookrc.5 index 0602c98..638b36f 100644 --- a/abookrc.5 +++ b/abookrc.5 @@ -1,4 +1,4 @@ -.TH ABOOKRC 5 "Jun 4, 2003" +.TH ABOOKRC 5 "Oct 25, 2005" .nh .SH NAME \fB$HOME/.abook/abookrc\fP \- configuration file for abook address book program @@ -27,53 +27,92 @@ Comments in .B abookrc are on lines beginning with '#'. -.SH VARIABLES - -.TP -\fBautosave\fP=[true|false] -Defines whether the addressbook is automatically saved on exit. Default is true. +.SH COMMANDS .TP -\fBshow_all_emails\fP=[true|false] -Defines whether all email addresses for a contact are shown in the main list view. Default is true +\fBset\fP \fIoption\fP = \fIvalue\fP .TP -\fBemailpos\fP=column -Defines the screen column on the main list where the email address is to begin. Default is 25. +\fBfield\fP \fIidentifier\fP = \fIhuman_readable_name\fP [ , \fItype\fP ] +Defines a new custom field. \fItype\fP can be one of 'string' (default) +, 'emails', 'list', or 'date'. .TP -\fBextra_column\fP=field -Defines the field to display in the extra (third) column on the main list. Default is "phone" (Home Phone). -.br -\fIfield\fP can be any of the following: -.br --1 disabled -.br -phone Home Phone -.br -workphone Work Phone +\fBview\fP \fIview name\fP = \fIfield1\fP [ , \fIfield2\fP, ... ] +Defines a view/tab, with \fIfieldN\fP being the identifier of a field +declared with the \fBfield\fP command, or the identifier of a standard field. +.IP +Standard fields: .br -fax Fax + name, email, .br -mobile Mobile Phone + address, address2, city, state, zip, country, .br -nick Nickname/Alias + phone, workphone, fax, mobile, .br -url URL -.br -notes Notes + nick, url, notes, anniversary +.IP +Note: if you don't define any view, abook will use a default display based +on the above standard fields. + + +.SH VARIABLES .TP -\fBextra_alternative\fP=field -This is an optional setting that allows you to specify an alternative field to be displayed in the extra (third) column if there is no data for the field specified in extra_column for a particular item. The strings for the fields are the same as above. Please note that the data shown where the alternative field has been used will NOT be marked differently in any way from the rest of the extra column. There is no default. +\fBautosave\fP=[true|false] +Defines whether the addressbook is automatically saved on exit. Default is true. .TP -\fBextrapos\fP=column -Defines the screen column on the main list where the extra field is to begin. Default is 65. +\fBpreserve_fields\fP=[all|standard|none] +Specifies how fields not declared with the \fBfield\fP command nor in a view +should be preserved while loading an abook database. +.RS +.TP +.B all +preserve any completely unknown field. +.TP +.B standard +only preserve the standard fields (see a list in the + description of the \fBview\fP command) and the legacy + 'custom[1-5]' fields. +.TP +.B none +discards any unknown field. +.RE +.IP +Default is \fIstandard\fP. .TP -\fBmutt_command\fP=command -Defines the command to start mutt. Default is "mutt". +\fBindex_format\fP=format_string +Defines the way entries are displayed in the main list. This is a string containing field names enclosed between braces, with an optional width limit specified by a number (right alignment if negative) after the field name and a colon, and an arbitrary number of alternative fields (first with non empty content is to be displayed) separated by vertical bars. For instance: +.RS +.TP +\fI{name:22}\fP +displays the \fIname\fP field with a maximal width of 22 characters. +.TP +\fI{phone:-13|workphone|mobile}\fP +displays (right aligned within a width of 13 characters), either the \fIphone\fP, \fIworkphone\fP or \fImobile\fP field, whichever being the first to be non-empty. +.RE +.IP +Default is \fI" {name:22} {email:40} {phone:12|workphone|mobile}"\fP + +.TP +\fBshow_all_emails\fP=[true|false] +Defines whether all email addresses for a contact are shown in the main list view. Default is true. + +.TP +.PD 0 +\fBemailpos\fP +.TP +.PD 0 +\fBextra_column\fP +.TP +.PD 0 +\fBextra_alternative\fP +.TP +.PD +\fBextrapos\fP +Obsoleted by \fBindex_format\fP. .TP \fBmutt_return_all_emails\fP=[true|false] @@ -113,31 +152,29 @@ Defines if the cursor is visible in main display. Default is false. # sample abook configuration file # -# Automatically save database on exit -set autosave=true +# Declare a few custom fields +field pager = Pager +field address_lines = Address, list +field birthday = Birthday, date -# Show all email addresses in list -set show_all_emails=true +# Define how fields should be displayed in tabs +view CONTACT = name, email +view ADDRESS = address_lines, city, state, zip, country +view PHONE = phone, workphone, pager, mobile, fax +view OTHER = url, birthday -# Screen column for email field to start -set emailpos=25 -# Field to be used in the extra column -set extra_column=phone -# frequently used values: -# -1 disabled -# phone Home Phone -# workphone Work Phone -# fax Fax -# mobile Mobile Phone -# nick Nickname/Alias -# url URL +# Preserve any unknown field while loading an abook database +set preserve_fields=all -# -set extra_alternative=-1 +# Automatically save database on exit +set autosave=true + +# Format of entries lines in list +set index_format=" {name:22} {email:40} {phone:12|workphone|mobile}" -# Screen column for the extra field to start -set extrapos=65 +# Show all email addresses in list +set show_all_emails=true # Command used to start mutt set mutt_command=mutt @@ -151,19 +188,19 @@ set print_command=lpr # Command used to start the web browser set www_command=lynx -# address style [eu|us|uk] +# Address style [eu|us|uk] set address_style=eu -# use ASCII characters only +# Use ASCII characters only set use_ascii_only=false # Prevent double entry set add_email_prevent_duplicates=false -# field to be used with "sort by field" command +# Field to be used with "sort by field" command set sort_field=nick -# show cursor in main display +# Show cursor in main display set show_cursor=false .fi @@ -171,8 +208,9 @@ set show_cursor=false .SH SEE ALSO .BR abook (1). .br -.SH AUTHOR -This manual page was written by Alan Ford . +.SH AUTHORS +This manual page was written by Alan Ford and +expanded by Cedric Duval . .br .B abook diff --git a/config.guess b/config.guess index ba66165..c38553d 100644 --- a/config.guess +++ b/config.guess @@ -1,9 +1,9 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. -timestamp='2001-04-20' +timestamp='2006-02-23' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -17,15 +17,18 @@ timestamp='2001-04-20' # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. -# Written by Per Bothner . -# Please send patches to . + +# Originally written by Per Bothner . +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and @@ -52,7 +55,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2000 +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO @@ -65,11 +68,11 @@ Try \`$me --help' for more information." while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; + echo "$timestamp" ; exit ;; --version | -v ) - echo "$version" ; exit 0 ;; + echo "$version" ; exit ;; --help | --h* | -h ) - echo "$usage"; exit 0 ;; + echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. @@ -87,33 +90,45 @@ if test $# != 0; then exit 1 fi +trap 'exit 1' 1 2 15 -dummy=dummy-$$ -trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. -# CC_FOR_BUILD -- compiler used by this script. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int dummy(){}" > $dummy.c - for c in cc gcc c89 ; do - ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 - if test $? = 0 ; then - CC_FOR_BUILD="$c"; break - fi - done - rm -f $dummy.c $dummy.o $dummy.rel + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found + CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac +esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 8/24/94.) +# (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi @@ -127,29 +142,31 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) - # Netbsd (nbsd) targets should (where applicable) match one or + # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. - # Determine the machine/vendor (is the vendor relevant). - case "${UNAME_MACHINE}" in - amiga) machine=m68k-unknown ;; - arm32) machine=arm-unknown ;; - atari*) machine=m68k-atari ;; - sun3*) machine=m68k-sun ;; - mac68k) machine=m68k-apple ;; - macppc) machine=powerpc-apple ;; - hp3[0-9][05]) machine=m68k-hp ;; - ibmrt|romp-ibm) machine=romp-ibm ;; - *) machine=${UNAME_MACHINE}-unknown ;; + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. - case "${UNAME_MACHINE}" in - i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k) + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep __ELF__ >/dev/null then @@ -165,116 +182,128 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # The OS release - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" - exit 0 ;; + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerppc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; alpha:OSF1:*:*) - if test $UNAME_RELEASE = "V4.0"; then + case $UNAME_RELEASE in + *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - fi + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - cat <$dummy.s - .data -\$Lformat: - .byte 37,100,45,37,120,10,0 # "%d-%x\n" - - .text - .globl main - .align 4 - .ent main -main: - .frame \$30,16,\$26,0 - ldgp \$29,0(\$27) - .prologue 1 - .long 0x47e03d80 # implver \$0 - lda \$2,-1 - .long 0x47e20c21 # amask \$2,\$1 - lda \$16,\$Lformat - mov \$0,\$17 - not \$1,\$18 - jsr \$26,printf - ldgp \$29,0(\$26) - mov 0,\$16 - jsr \$26,exit - .end main -EOF - $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null - if test "$?" = 0 ; then - case `./$dummy` in - 0-0) - UNAME_MACHINE="alpha" - ;; - 1-0) - UNAME_MACHINE="alphaev5" - ;; - 1-1) - UNAME_MACHINE="alphaev56" - ;; - 1-101) - UNAME_MACHINE="alphapca56" - ;; - 2-303) - UNAME_MACHINE="alphaev6" - ;; - 2-307) - UNAME_MACHINE="alphaev67" - ;; - esac - fi - rm -f $dummy.s $dummy - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit 0 ;; + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix - exit 0 ;; + exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 - exit 0 ;; + exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 - exit 0;; - amiga:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; + exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos - exit 0 ;; - arc64:OpenBSD:*:*) - echo mips64el-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - arc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - hkmips:OpenBSD:*:*) - echo mips-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - pmax:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sgi:OpenBSD:*:*) - echo mips-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - wgrisc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; *:OS/390:*:*) echo i370-ibm-openedition - exit 0 ;; + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} - exit 0;; + exit ;; + arm:riscos:*:*|arm:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp - exit 0;; + exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then @@ -282,25 +311,32 @@ EOF else echo pyramid-pyramid-bsd fi - exit 0 ;; + exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 - exit 0 ;; + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + exit ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) @@ -309,12 +345,12 @@ EOF esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit 0 ;; + exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} - exit 0 ;; + exit ;; sun*:*:4.2BSD:*) - UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) @@ -324,13 +360,10 @@ EOF echo sparc-sun-sunos${UNAME_RELEASE} ;; esac - exit 0 ;; + exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} - exit 0 ;; - atari*:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; + exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor @@ -341,50 +374,42 @@ EOF # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; + exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; + exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; + exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} - exit 0 ;; + exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} - exit 0 ;; + exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} - exit 0 ;; - sun3*:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} - exit 0 ;; + exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 - exit 0 ;; + exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} - exit 0 ;; + exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} - exit 0 ;; + exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} - exit 0 ;; + exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ @@ -406,27 +431,33 @@ EOF exit (-1); } EOF - $CC_FOR_BUILD $dummy.c -o $dummy \ - && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ - && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} - exit 0 ;; + exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax - exit 0 ;; + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix - exit 0 ;; + exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 - exit 0 ;; + exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 - exit 0 ;; + exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 - exit 0 ;; + exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` @@ -442,29 +473,29 @@ EOF else echo i586-dg-dgux${UNAME_RELEASE} fi - exit 0 ;; + exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 - exit 0 ;; + exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 - exit 0 ;; + exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 - exit 0 ;; + exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd - exit 0 ;; + exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit 0 ;; + exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix - exit 0 ;; + exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` @@ -472,9 +503,10 @@ EOF IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit 0 ;; + exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include @@ -486,17 +518,20 @@ EOF exit(0); } EOF - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - echo rs6000-ibm-aix3.2.5 + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi - exit 0 ;; + exit ;; *:AIX:*:[45]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else @@ -508,38 +543,36 @@ EOF IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit 0 ;; + exit ;; *:AIX:*:*) echo rs6000-ibm-aix - exit 0 ;; + exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 - exit 0 ;; + exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit 0 ;; # report: romp-ibm BSD 4.3 + exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx - exit 0 ;; + exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 - exit 0 ;; + exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd - exit 0 ;; + exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 - exit 0 ;; + exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) - case "${HPUX_REV}" in - 11.[0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 @@ -548,12 +581,13 @@ EOF case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac - fi ;; - esac - if [ "${HP_ARCH}" = "" ]; then - sed 's/^ //' << EOF >$dummy.c + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include @@ -586,18 +620,39 @@ EOF exit (0); } EOF - (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` - if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi - rm -f $dummy.c $dummy - fi ;; + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep __LP64__ >/dev/null + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit 0 ;; + exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} - exit 0 ;; + exit ;; 3050*:HI-UX:*:*) + eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int @@ -623,239 +678,246 @@ EOF exit (0); } EOF - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 - exit 0 ;; + exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd - exit 0 ;; + exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd - exit 0 ;; - *9??*:MPE/iX:*:*) + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix - exit 0 ;; + exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf - exit 0 ;; + exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf - exit 0 ;; + exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi - exit 0 ;; + exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites - exit 0 ;; - hppa*:OpenBSD:*:*) - echo hppa-unknown-openbsd - exit 0 ;; + exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd - exit 0 ;; + exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi - exit 0 ;; + exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd - exit 0 ;; + exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd - exit 0 ;; + exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd - exit 0 ;; - CRAY*X-MP:*:*:*) - echo xmp-cray-unicos - exit 0 ;; + exit ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} - exit 0 ;; + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ - exit 0 ;; + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*T3D:*:*:*) - echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; + exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; + exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY-2:*:*:*) - echo cray2-cray-unicos - exit 0 ;; + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit 0 ;; - hp300:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit 0 ;; + exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; + exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; + exit ;; *:FreeBSD:*:*) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit 0 ;; - *:OpenBSD:*:*) - echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - exit 0 ;; + case ${UNAME_MACHINE} in + pc98) + echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin - exit 0 ;; + exit ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 - exit 0 ;; + exit ;; + i*:MSYS_NT-*:*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 - exit 0 ;; + exit ;; + x86:Interix*:[345]*) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + EM64T:Interix*:[345]*) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? - echo i386-pc-interix - exit 0 ;; + echo i586-pc-interix + exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin - exit 0 ;; + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin - exit 0 ;; + exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + exit ;; *:GNU:*:*) + # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit 0 ;; + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix - exit 0 ;; + exit ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + exit ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit ;; + crisv32:Linux:*:*) + echo crisv32-axis-linux-gnu + exit ;; + frv:Linux:*:*) + echo frv-unknown-linux-gnu + exit ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux - exit 0 ;; + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + exit ;; mips:Linux:*:*) - cat >$dummy.c < /* for printf() prototype */ -int main (int argc, char *argv[]) { -#else -int main (argc, argv) int argc; char *argv[]; { -#endif -#ifdef __MIPSEB__ - printf ("%s-unknown-linux-gnu\n", argv[1]); -#endif -#ifdef __MIPSEL__ - printf ("%sel-unknown-linux-gnu\n", argv[1]); -#endif - return 0; -} + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif EOF - $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; - ppc:Linux:*:*) - # Determine Lib Version - cat >$dummy.c < -#if defined(__GLIBC__) -extern char __libc_version[]; -extern char __libc_release[]; -#endif -main(argc, argv) - int argc; - char *argv[]; -{ -#if defined(__GLIBC__) - printf("%s %s\n", __libc_version, __libc_release); -#else - printf("unknown\n"); -#endif - return 0; -} + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif EOF - LIBC="" - $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null - if test "$?" = 0 ; then - ./$dummy | grep 1\.99 > /dev/null - if test "$?" = 0 ; then LIBC="libc1" ; fi - fi - rm -f $dummy.c $dummy - echo powerpc-unknown-linux-gnu${LIBC} - exit 0 ;; + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + or32:Linux:*:*) + echo or32-unknown-linux-gnu + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit ;; alpha:Linux:*:*) - cat <$dummy.s - .data - \$Lformat: - .byte 37,100,45,37,120,10,0 # "%d-%x\n" - .text - .globl main - .align 4 - .ent main - main: - .frame \$30,16,\$26,0 - ldgp \$29,0(\$27) - .prologue 1 - .long 0x47e03d80 # implver \$0 - lda \$2,-1 - .long 0x47e20c21 # amask \$2,\$1 - lda \$16,\$Lformat - mov \$0,\$17 - not \$1,\$18 - jsr \$26,printf - ldgp \$29,0(\$26) - mov 0,\$16 - jsr \$26,exit - .end main -EOF - LIBC="" - $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null - if test "$?" = 0 ; then - case `./$dummy` in - 0-0) UNAME_MACHINE="alpha" ;; - 1-0) UNAME_MACHINE="alphaev5" ;; - 1-1) UNAME_MACHINE="alphaev56" ;; - 1-101) UNAME_MACHINE="alphapca56" ;; - 2-303) UNAME_MACHINE="alphaev6" ;; - 2-307) UNAME_MACHINE="alphaev67" ;; - esac - objdump --private-headers $dummy | \ - grep ld.so.1 > /dev/null - if test "$?" = 0 ; then - LIBC="libc1" - fi - fi - rm -f $dummy.s $dummy + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} - exit 0 ;; + exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in @@ -863,93 +925,97 @@ EOF PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac - exit 0 ;; + exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu - exit 0 ;; + exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux - exit 0 ;; + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-gnu + exit ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu - exit 0 ;; + exit ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. - ld_supported_emulations=`cd /; ld --help 2>&1 \ - | sed -ne '/supported emulations:/!d + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ + | sed -ne '/supported targets:/!d s/[ ][ ]*/ /g - s/.*supported emulations: *// + s/.*supported targets: *// s/ .*// p'` - case "$ld_supported_emulations" in - i*86linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit 0 - ;; - elf_i*86) + case "$ld_supported_targets" in + elf32-i386) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; - i*86coff) + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit ;; + coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit 0 - ;; - esac - # Either a pre-BFD a.out linker (linux-gnuoldld) - # or one that does not give us useful --help. - # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout. - # If ld does not provide *any* "supported emulations:" - # that means it is gnuoldld. - test -z "$ld_supported_emulations" && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 - case "${UNAME_MACHINE}" in - i*86) - VENDOR=pc; - ;; - *) - VENDOR=unknown; - ;; + exit ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit ;; esac # Determine whether the default compiler is a.out or elf - cat >$dummy.c < -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif -#ifdef __ELF__ -# ifdef __GLIBC__ -# if __GLIBC__ >= 2 - printf ("%s-${VENDOR}-linux-gnu\n", argv[1]); -# else - printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); -# endif -# else - printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); -# endif -#else - printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]); -#endif - return 0; -} + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__sun) + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif + #ifdef __dietlibc__ + LIBC=dietlibc + #endif EOF - $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^LIBC/{ + s: ::g + p + }'`" + test x"${LIBC}" != x && { + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + exit + } + test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } ;; -# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions -# are messed up and put the nodename in both sysname and nodename. i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. echo i386-sequent-sysv4 - exit 0 ;; + exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... @@ -957,7 +1023,27 @@ EOF # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit 0 ;; + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then @@ -965,100 +1051,100 @@ EOF else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi - exit 0 ;; - i*86:*:5:7*) - # Fixed at (any) Pentium or better - UNAME_MACHINE=i586 - if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then - echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} - fi - exit 0 ;; + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` - (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 - (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 - (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi - exit 0 ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit 0 ;; + exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i386. echo i386-pc-msdosdjgpp - exit 0 ;; + exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 - exit 0 ;; + exit ;; paragon:*:*:*) echo i860-intel-osf1 - exit 0 ;; + exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi - exit 0 ;; + exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv - exit 0 ;; - M68*:*:R3V[567]*:*) - test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4 && exit 0 ;; + && { echo i486-ncr-sysv4; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 - exit 0 ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} - exit 0 ;; + exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 - exit 0 ;; + exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 - exit 0 ;; + exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` @@ -1066,78 +1152,98 @@ EOF else echo ns32k-sni-sysv fi - exit 0 ;; - PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says echo i586-unisys-sysv4 - exit 0 ;; + exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 - exit 0 ;; + exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 - exit 0 ;; + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} - exit 0 ;; + exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 - exit 0 ;; + exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi - exit 0 ;; + exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos - exit 0 ;; + exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos - exit 0 ;; + exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos - exit 0 ;; + exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} - exit 0 ;; + exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} - exit 0 ;; + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; + exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; + exit ;; *:Darwin:*:*) - echo `uname -p`-apple-darwin${UNAME_RELEASE} - exit 0 ;; + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) - if test "${UNAME_MACHINE}" = "x86pc"; then + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo `uname -p`-${UNAME_MACHINE}-nto-qnx - exit 0 ;; + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; *:QNX:*:4*) echo i386-pc-qnx - exit 0 ;; - NSR-[KW]:NONSTOP_KERNEL:*:*) + exit ;; + NSE-?:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} - exit 0 ;; + exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux - exit 0 ;; + exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv - exit 0 ;; + exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit 0 ;; + exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 @@ -1148,35 +1254,53 @@ EOF UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 - exit 0 ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit 0 ;; + exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 - exit 0 ;; + exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex - exit 0 ;; + exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 - exit 0 ;; + exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 - exit 0 ;; + exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 - exit 0 ;; + exit ;; *:ITS:*:*) echo pdp10-unknown-its - exit 0 ;; + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 +eval $set_cc_for_build cat >$dummy.c < @@ -1202,7 +1326,7 @@ main () #endif #if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix"); exit (0); + printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) @@ -1291,12 +1415,12 @@ main () } EOF -$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 -rm -f $dummy.c $dummy +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) @@ -1305,22 +1429,22 @@ then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd - exit 0 ;; + exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi - exit 0 ;; + exit ;; c34*) echo c34-convex-bsd - exit 0 ;; + exit ;; c38*) echo c38-convex-bsd - exit 0 ;; + exit ;; c4*) echo c4-convex-bsd - exit 0 ;; + exit ;; esac fi @@ -1331,7 +1455,9 @@ This script, last modified $timestamp, has failed to recognize the operating system you are using. It is advised that you download the most up to date version of the config scripts from - ftp://ftp.gnu.org/pub/gnu/config/ + http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess +and + http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub If the version you run ($0) is already up to date, please send the following data and any information you think might be diff --git a/config.sub b/config.sub index a06a480..ad9f395 100644 --- a/config.sub +++ b/config.sub @@ -1,9 +1,9 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. -timestamp='2001-04-20' +timestamp='2006-02-23' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -21,15 +21,17 @@ timestamp='2001-04-20' # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. -# Please send patches to . + +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. @@ -69,7 +71,7 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO @@ -82,11 +84,11 @@ Try \`$me --help' for more information." while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; + echo "$timestamp" ; exit ;; --version | -v ) - echo "$version" ; exit 0 ;; + echo "$version" ; exit ;; --help | --h* | -h ) - echo "$usage"; exit 0 ;; + echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. @@ -98,7 +100,7 @@ while test $# -gt 0 ; do *local*) # First pass through any local machine types. echo $1 - exit 0;; + exit ;; * ) break ;; @@ -117,7 +119,9 @@ esac # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | storm-chaos* | os2-emx*) + nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ + uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; @@ -143,7 +147,7 @@ case $os in -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis) + -apple | -axis | -knuth | -cray) os= basic_machine=$1 ;; @@ -157,9 +161,21 @@ case $os in os=-vxworks basic_machine=$1 ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; -hiux*) os=-hiuxwe2 ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` @@ -176,6 +192,10 @@ case $os in # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` @@ -215,26 +235,58 @@ esac case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. - tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc \ - | arm | arme[lb] | arm[bl]e | armv[2345] | armv[345][lb] | strongarm | xscale \ - | pyramid | mn10200 | mn10300 | tron | a29k \ - | 580 | i960 | h8300 \ - | x86 | ppcbe | mipsbe | mipsle | shbe | shle \ - | hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \ - | hppa64 \ - | alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \ - | alphaev6[78] \ - | we32k | ns16k | clipper | i370 | sh | sh[34] \ - | powerpc | powerpcle \ - | 1750a | dsp16xx | pdp10 | pdp11 \ - | mips16 | mips64 | mipsel | mips64el \ - | mips64orion | mips64orionel | mipstx39 | mipstx39el \ - | mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \ - | mips64vr5000 | miprs64vr5000el | mcore | s390 | s390x \ - | sparc | sparclet | sparclite | sparc64 | sparcv9 | sparcv9b \ - | v850 | c4x \ - | thumb | d10v | d30v | fr30 | avr | openrisc | tic80 \ - | pj | pjl | h8500) + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ + | bfin \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | m32r | m32rle | m68000 | m68k | m88k | maxq | mb | microblaze | mcore \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64vr | mips64vrel \ + | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | mt \ + | msp430 \ + | nios | nios2 \ + | ns16k | ns32k \ + | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b \ + | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ + | v850 | v850e \ + | we32k \ + | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \ + | z8k) + basic_machine=$basic_machine-unknown + ;; + m32c) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) @@ -242,7 +294,10 @@ case $basic_machine in basic_machine=$basic_machine-unknown os=-none ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | w65) + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-unknown ;; # We use `pc' rather than `unknown' @@ -257,31 +312,68 @@ case $basic_machine in exit 1 ;; # Recognize the basic CPU types with company name. - # FIXME: clean up the formatting here. - vax-* | tahoe-* | i*86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \ - | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | c[123]* \ - | arm-* | armbe-* | armle-* | armv*-* | strongarm-* | xscale-* \ - | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ - | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \ - | xmp-* | ymp-* \ - | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* \ - | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \ - | hppa2.0n-* | hppa64-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \ - | alphaev6[78]-* \ - | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \ - | clipper-* | orion-* \ - | sparclite-* | pdp10-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \ - | sparc64-* | sparcv9-* | sparcv9b-* | sparc86x-* \ - | mips16-* | mips64-* | mipsel-* \ - | mips64el-* | mips64orion-* | mips64orionel-* \ - | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \ - | mipstx39-* | mipstx39el-* | mcore-* \ - | f30[01]-* | f700-* | s390-* | s390x-* | sv1-* | t3e-* \ - | [cjt]90-* \ - | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \ - | thumb-* | v850-* | d30v-* | tic30-* | tic80-* | c30-* | fr30-* \ - | bs2000-* | tic54x-* | c54x-* | x86_64-* | pj-* | pjl-*) + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nios-* | nios2-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tron-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \ + | xstormy16-* | xtensa-* \ + | ymp-* \ + | z8k-*) + ;; + m32c-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. @@ -299,6 +391,9 @@ case $basic_machine in basic_machine=a29k-amd os=-udi ;; + abacus) + basic_machine=abacus-unknown + ;; adobe68k) basic_machine=m68010-adobe os=-scout @@ -313,6 +408,12 @@ case $basic_machine in basic_machine=a29k-none os=-bsd ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; amdahl) basic_machine=580-amdahl os=-sysv @@ -344,6 +445,10 @@ case $basic_machine in basic_machine=ns32k-sequent os=-dynix ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; convex-c1) basic_machine=c1-convex os=-bsd @@ -364,30 +469,45 @@ case $basic_machine in basic_machine=c38-convex os=-bsd ;; - cray | ymp) - basic_machine=ymp-cray + cray | j90) + basic_machine=j90-cray os=-unicos ;; - cray2) - basic_machine=cray2-cray - os=-unicos + craynv) + basic_machine=craynv-cray + os=-unicosmp ;; - [cjt]90) - basic_machine=${basic_machine}-cray - os=-unicos + cr16c) + basic_machine=cr16c-unknown + os=-elf ;; crds | unos) basic_machine=m68k-crds ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola @@ -396,6 +516,10 @@ case $basic_machine in basic_machine=m88k-motorola os=-sysv3 ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx @@ -568,32 +692,27 @@ case $basic_machine in basic_machine=m68k-atari os=-mint ;; - mipsel*-linux*) - basic_machine=mipsel-unknown - os=-linux-gnu - ;; - mips*-linux*) - basic_machine=mips-unknown - os=-linux-gnu - ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; - mmix*) - basic_machine=mmix-knuth - os=-mmixware - ;; monitor) basic_machine=m68k-rom68k os=-coff ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; msdos) basic_machine=i386-pc os=-msdos ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; mvs) basic_machine=i370-ibm os=-mvs @@ -669,6 +788,13 @@ case $basic_machine in basic_machine=hppa1.1-oki os=-proelf ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose @@ -691,42 +817,64 @@ case $basic_machine in pbb) basic_machine=m68k-tti ;; - pc532 | pc532-*) + pc532 | pc532-*) basic_machine=ns32k-pc532 ;; - pentium | p5 | k5 | k6 | nexgen) + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; - pentiumpro | p6 | 6x86 | athlon) + pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; - pentiumii | pentium2) + pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-*) + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - pentiumii-* | pentium2-*) + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown - ;; + ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown - ;; + ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; ps2) basic_machine=i386-ibm ;; @@ -734,6 +882,10 @@ case $basic_machine in basic_machine=i586-unknown os=-pw32 ;; + rdos) + basic_machine=i386-pc + os=-rdos + ;; rom68k) basic_machine=m68k-rom68k os=-coff @@ -744,10 +896,26 @@ case $basic_machine in rtpc | rtpc-*) basic_machine=romp-ibm ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; sa29200) basic_machine=a29k-amd os=-udi ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; sequent) basic_machine=i386-sequent ;; @@ -755,7 +923,10 @@ case $basic_machine in basic_machine=sh-hitachi os=-hms ;; - sparclite-wrs) + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; @@ -822,22 +993,42 @@ case $basic_machine in os=-dynix ;; t3e) - basic_machine=t3e-cray + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; tower | tower-32) basic_machine=m68k-ncr ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; udi29k) basic_machine=a29k-amd os=-udi @@ -859,8 +1050,8 @@ case $basic_machine in os=-vms ;; vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; + basic_machine=f301-fujitsu + ;; vxworks960) basic_machine=i960-wrs os=-vxworks @@ -881,13 +1072,17 @@ case $basic_machine in basic_machine=hppa1.1-winbond os=-proelf ;; - xmp) - basic_machine=xmp-cray - os=-unicos + xbox) + basic_machine=i686-pc + os=-mingw32 ;; - xps | xps100) + xps | xps100) basic_machine=xps100-honeywell ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim @@ -908,16 +1103,12 @@ case $basic_machine in op60c) basic_machine=hppa1.1-oki ;; - mips) - if [ x$os = x-linux-gnu ]; then - basic_machine=mips-unknown - else - basic_machine=mips-mips - fi - ;; romp) basic_machine=romp-ibm ;; + mmix) + basic_machine=mmix-knuth + ;; rs6000) basic_machine=rs6000-ibm ;; @@ -934,13 +1125,13 @@ case $basic_machine in we32k) basic_machine=we32k-att ;; - sh3 | sh4) + sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; - sparc | sparcv9 | sparcv9b) + sparc | sparcv8 | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; - cydra) + cydra) basic_machine=cydra-cydrome ;; orion) @@ -955,10 +1146,6 @@ case $basic_machine in pmac | pmac-mpw) basic_machine=powerpc-apple ;; - c4x*) - basic_machine=c4x-none - os=-coff - ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; @@ -1014,15 +1201,23 @@ case $os in | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ - | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -openbsd* | -solidbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ + | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* | -os2*) + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1034,16 +1229,21 @@ case $os in ;; esac ;; + -nto-qnx*) + ;; -nto*) - os=-nto-qnx + os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; @@ -1056,6 +1256,9 @@ case $os in -opened*) os=-openedition ;; + -os400*) + os=-os400 + ;; -wince*) os=-wince ;; @@ -1074,14 +1277,23 @@ case $os in -acis*) os=-aos ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; + -nova*) + os=-rtmk-nova + ;; -ns2 ) - os=-nextstep2 + os=-nextstep2 ;; -nsk*) os=-nsk @@ -1093,6 +1305,9 @@ case $os in -sinix*) os=-sysv4 ;; + -tpf*) + os=-tpf + ;; -triton*) os=-sysv3 ;; @@ -1120,8 +1335,17 @@ case $os in -xenix) os=-xenix ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; + -zvmoe) + os=-zvmoe ;; -none) ;; @@ -1154,10 +1378,14 @@ case $basic_machine in arm*-semi) os=-aout ;; + c4x-* | tic4x-*) + os=-coff + ;; + # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; - pdp11-*) + pdp11-*) os=-none ;; *-dec | vax-*) @@ -1184,6 +1412,9 @@ case $basic_machine in mips*-*) os=-elf ;; + or32-*) + os=-coff + ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; @@ -1193,9 +1424,15 @@ case $basic_machine in *-be) os=-beos ;; + *-haiku) + os=-haiku + ;; *-ibm) os=-aix ;; + *-knuth) + os=-mmixware + ;; *-wec) os=-proelf ;; @@ -1247,19 +1484,19 @@ case $basic_machine in *-next) os=-nextstep3 ;; - *-gould) + *-gould) os=-sysv ;; - *-highlevel) + *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; - *-sgi) + *-sgi) os=-irix ;; - *-siemens) + *-siemens) os=-sysv4 ;; *-masscomp) @@ -1328,10 +1565,16 @@ case $basic_machine in -mvs* | -opened*) vendor=ibm ;; + -os400*) + vendor=ibm + ;; -ptx*) vendor=sequent ;; - -vxsim* | -vxworks*) + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) @@ -1346,13 +1589,16 @@ case $basic_machine in -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; + -vos*) + vendor=stratus + ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os -exit 0 +exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) diff --git a/configure b/configure index 0dc4124..fdbd0d5 100755 --- a/configure +++ b/configure @@ -1622,7 +1622,7 @@ fi # Define the identity of the package. PACKAGE=abook - VERSION=0.5.6 + VERSION=0.6.0pre2 cat >>confdefs.h <<_ACEOF @@ -10193,8 +10193,10 @@ _ACEOF abook_localedir="$datadir/locale" - abook_localedir=`( test "x$prefix" = xNONE && prefix="$ac_default_prefix" - eval echo \""$abook_localedir"\" )` + abook_localedir=`( test "x$prefix" = xNONE && prefix="$ac_default_prefix" + eval tmp_abook_prefix=\""$abook_localedir"\" + eval echo $tmp_abook_prefix + )` localedir="\$(datadir)/locale" diff --git a/configure.in b/configure.in index e6cc922..105cf55 100644 --- a/configure.in +++ b/configure.in @@ -1,7 +1,7 @@ dnl abook configure.in AC_INIT(abook.c) -AM_INIT_AUTOMAKE(abook, 0.5.6) +AM_INIT_AUTOMAKE(abook, 0.6.0pre2) AM_CONFIG_HEADER(config.h) dnl --------------- @@ -13,8 +13,12 @@ AM_GNU_GETTEXT_VERSION(0.14.1) AC_DEFUN([ABOOK_EXPAND_PREFIX], [ $1=$2 + dnl expanding twice, since from autoconf 2.60 on, $datadir refers to + dnl $datarootdir which in turn refers to $prefix $1=`( test "x$prefix" = xNONE && prefix="$ac_default_prefix" - eval echo \""[$]$1"\" )` + eval tmp_abook_prefix=\""[$]$1"\" + eval echo $tmp_abook_prefix + )` ]) ABOOK_EXPAND_PREFIX(abook_localedir, "$datadir/locale") diff --git a/contrib/CVS/Entries b/contrib/CVS/Entries new file mode 100644 index 0000000..1784810 --- /dev/null +++ b/contrib/CVS/Entries @@ -0,0 +1 @@ +D diff --git a/contrib/CVS/Repository b/contrib/CVS/Repository new file mode 100644 index 0000000..cb97fad --- /dev/null +++ b/contrib/CVS/Repository @@ -0,0 +1 @@ +abook/contrib diff --git a/contrib/CVS/Root b/contrib/CVS/Root new file mode 100644 index 0000000..2f2a68d --- /dev/null +++ b/contrib/CVS/Root @@ -0,0 +1 @@ +:ext:jheinonen@abook.cvs.sourceforge.net:/cvsroot/abook diff --git a/database.c b/database.c index cabd330..7c47ab6 100644 --- a/database.c +++ b/database.c @@ -1,6 +1,6 @@ /* - * $Id: database.c,v 1.29.2.1 2005/10/26 19:45:23 jheinonen Exp $ + * $Id: database.c,v 1.39 2006/09/04 18:29:25 cduval Exp $ * * by JH * @@ -11,82 +11,233 @@ #include #include #include -#include -#include "abook.h" #include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#include "abook.h" #include "database.h" #include "gettext.h" #include "list.h" #include "misc.h" -#include "options.h" -#include "filter.h" #include "xmalloc.h" -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif + +abook_field_list *fields_list = NULL; +int fields_count = 0; list_item *database = NULL; +static int items = 0; -int items = 0; +#define ITEM_SIZE (fields_count * sizeof(char *)) +#define LAST_ITEM (items - 1) #define INITIAL_LIST_CAPACITY 30 - static int list_capacity = 0; +int standard_fields_indexed[ITEM_FIELDS]; + +/* + * notes about adding predefined "standard" fields: + * - leave alone "name" and "email" + * - reorganize the field numbers in database.h + */ +abook_field standard_fields[] = { + {"name", N_("Name"), FIELD_STRING}, /* NAME */ + {"email", N_("E-mail addresses"), FIELD_EMAILS}, /* EMAIL */ + {"address", N_("Address"), FIELD_STRING}, /* ADDRESS */ + {"address2", N_("Address2"), FIELD_STRING}, /* ADDRESS2 */ + {"city", N_("City"), FIELD_STRING}, /* CITY */ + {"state", N_("State/Province"), FIELD_STRING}, /* STATE */ + {"zip", N_("ZIP/Postal Code"), FIELD_STRING}, /* ZIP */ + {"country", N_("Country"), FIELD_STRING}, /* COUNTRY */ + {"phone", N_("Home Phone"), FIELD_STRING}, /* PHONE */ + {"workphone", N_("Work Phone"), FIELD_STRING}, /* WORKPHONE */ + {"fax", N_("Fax"), FIELD_STRING}, /* FAX */ + {"mobile", N_("Mobile"), FIELD_STRING}, /* MOBILEPHONE */ + {"nick", N_("Nickname/Alias"), FIELD_STRING}, /* NICK */ + {"url", N_("URL"), FIELD_STRING}, /* URL */ + {"notes", N_("Notes"), FIELD_STRING}, /* NOTES */ + {"anniversary", N_("Anniversary day"), FIELD_DATE}, /* ANNIVERSARY */ + {0} /* ITEM_FIELDS */ +}; + + extern int first_list_item; extern int curitem; extern char *selected; - extern char *datafile; + + +static abook_field * +declare_standard_field(int i) +{ + abook_field *f = xmalloc(sizeof(abook_field)); + + f = memcpy(f, &standard_fields[i], sizeof(abook_field)); + f->name = xstrdup(gettext(f->name)); + + add_field(&fields_list, f); + + assert(standard_fields_indexed[i] == -1); + standard_fields_indexed[i] = fields_count++; + + return f; +} + +abook_field * +find_standard_field(char *key, int do_declare) +{ + int i; + + for(i = 0; standard_fields[i].key; i++) + if(0 == strcmp(standard_fields[i].key, key)) + goto found; + + return NULL; + +found: + return do_declare ? declare_standard_field(i) : &standard_fields[i]; +} + +/* Search for a field. Use the list of declared fields if no list specified. */ +abook_field * +real_find_field(char *key, abook_field_list *list, int *number) +{ + abook_field_list *cur; + int i; + + for(cur = (list ? list : fields_list), i = 0; cur; cur = cur->next, i++) + if(0 == strcmp(cur->field->key, key)) { + if(number) + *number = i; + return cur->field; + } + + if(number) + *number = -1; + + return NULL; +} + +void +get_field_info(int i, char **key, char **name, int *type) +{ + abook_field_list *cur = fields_list; + int j; + + assert(i < fields_count); + + for(j = 0; i >= 0 && j < i; j++, cur = cur->next) + ; + + if(key) + *key = (i < 0) ? NULL : cur->field->key; + if(name) + *name = (i < 0) ? NULL : cur->field->name; + if(type) + *type = (i < 0) ? -1 : cur->field->type; +} + +void +add_field(abook_field_list **list, abook_field *f) +{ + abook_field_list *tmp; + + for(tmp = *list; tmp && tmp->next; tmp = tmp->next) + ; + + if(tmp) { + tmp->next = xmalloc(sizeof(abook_field_list)); + tmp = tmp->next; + } else + *list = tmp = xmalloc(sizeof(abook_field_list)); + + tmp->field = f; + tmp->next = NULL; +} + +char * +declare_new_field(char *key, char *name, char *type, int accept_standard) +{ + abook_field *f; + + if(find_declared_field(key)) + return _("field already defined"); + + if(find_standard_field(key, accept_standard)) + return accept_standard ? NULL /* ok, added */ : + _("standard field does not need to be declared"); + + f = xmalloc(sizeof(abook_field)); + f->key = xstrdup(key); + f->name = xstrdup(name); + + if(!*type || (0 == strcasecmp("string", type))) + f->type = FIELD_STRING; + else if(0 == strcasecmp("emails", type)) + f->type = FIELD_EMAILS; + else if(0 == strcasecmp("list", type)) + f->type = FIELD_LIST; + else if(0 == strcasecmp("date", type)) + f->type = FIELD_DATE; + else + return _("unknown type"); + + add_field(&fields_list, f); + fields_count++; + + return NULL; +} + /* - * field definitions + * Declare a new field while database is already loaded + * making it grow accordingly */ +static void +declare_unknown_field(char *key) +{ + int i; + + declare_new_field(key, key, "string", + 1 /* accept to declare "standard" fields */); -#include "edit.h" + if(!database) + return; + + for(i = 0; i < items; i++) + if(database[i]) { + database[i] = xrealloc(database[i], ITEM_SIZE); + database[i][fields_count - 1] = NULL; + } +} /* - * notes about adding fields: - * - do not change any fields in TAB_CONTACT - * - do not add fields to contact tab - * - 6 fields per tab is maximum - * - reorganize the field numbers in database.h + * Declare "standard" fields, thus preserving them while parsing a database, + * even if they won't be displayed. */ +void +init_standard_fields() +{ + int i; -struct abook_field abook_fields[ITEM_FIELDS] = { - {N_("Name"), "name", TAB_CONTACT},/* NAME */ - {N_("E-mails"), "email", TAB_CONTACT},/* EMAIL */ - {N_("Address"), "address", TAB_ADDRESS},/* ADDRESS */ - {N_("Address2"), "address2", TAB_ADDRESS},/* ADDRESS2 */ - {N_("City"), "city", TAB_ADDRESS},/* CITY */ - {N_("State/Province"),"state", TAB_ADDRESS},/* STATE */ - {N_("ZIP/Postal Code"),"zip", TAB_ADDRESS},/* ZIP */ - {N_("Country"), "country", TAB_ADDRESS},/* COUNTRY */ - {N_("Home Phone"), "phone", TAB_PHONE},/* PHONE */ - {N_("Work Phone"), "workphone", TAB_PHONE},/* WORKPHONE */ - {N_("Fax"), "fax", TAB_PHONE},/* FAX */ - {N_("Mobile"), "mobile", TAB_PHONE},/* MOBILEPHONE */ - {N_("Nickname/Alias"), "nick", TAB_OTHER},/* NICK */ - {N_("URL"), "url", TAB_OTHER},/* URL */ - {N_("Notes"), "notes", TAB_OTHER},/* NOTES */ - {N_("Custom1"), "custom1", TAB_CUSTOM},/* CUSTOM1 */ - {N_("Custom2"), "custom2", TAB_CUSTOM},/* CUSTOM2 */ - {N_("Custom3"), "custom3", TAB_CUSTOM},/* CUSTOM3 */ - {N_("Custom4"), "custom4", TAB_CUSTOM},/* CUSTOM4 */ - {N_("Custom5"), "custom5", TAB_CUSTOM},/* CUSTOM5 */ -}; - + for(i = 0; standard_fields[i].key; i++) + if(standard_fields_indexed[i] == -1) + declare_standard_field(i); +} -int -find_field(const char *field) +/* Some initializations - Must be called _before_ load_opts() */ +void +prepare_database_internals() { int i; for(i = 0; i < ITEM_FIELDS; i++) - if( !strcmp(abook_fields[i].key, field) ) - return i; + standard_fields_indexed[i] = -1; - return -1; + /* the only two mandatory fields */ + declare_standard_field(NAME); + declare_standard_field(EMAIL); } int @@ -94,50 +245,57 @@ parse_database(FILE *in) { char *line = NULL; char *tmp; - int sec=0, i; - list_item item; + int sec=0, field; + list_item item; - memset(&item, 0, sizeof(item)); + item = item_create(); for(;;) { line = getaline(in); if(feof(in)) { - if(item[NAME] && sec) + if(item[field_id(NAME)] && sec) { add_item2database(item); - else - free_list_item(item); + } else { + item_empty(item); + } break; } if(!*line || *line == '\n' || *line == '#') { goto next; } else if(*line == '[') { - if( item[NAME] && sec ) + if(item[field_id(NAME)] && sec ) { add_item2database(item); - else - free_list_item(item); - memset(&item, 0, sizeof(item)); + } else { + item_empty(item); + } sec = 1; + memset(item, 0, ITEM_SIZE); if(!(tmp = strchr(line, ']'))) sec = 0; /*incorrect section lines are skipped*/ } else if((tmp = strchr(line, '=') ) && sec) { *tmp++ = '\0'; - for(i = 0; i < ITEM_FIELDS; i++) - if(!strcmp(abook_fields[i].key, line)) { - item[i] = xstrdup(tmp); - goto next; - } + find_field_number(line, &field); + if(field != -1) { + item[field] = xstrdup(tmp); + goto next; + } else if(!strcasecmp(opt_get_str(STR_PRESERVE_FIELDS), + "all")){ + declare_unknown_field(line); + item = xrealloc(item, ITEM_SIZE); + item[fields_count - 1] = xstrdup(tmp); + goto next; + } } next: xfree(line); } xfree(line); + item_free(&item); return 0; } - - int load_database(char *filename) { @@ -159,6 +317,7 @@ write_database(FILE *out, struct db_enumerator e) { int j; int i = 0; + abook_field_list *cur; fprintf(out, "# abook addressbook file\n\n" @@ -170,14 +329,16 @@ write_database(FILE *out, struct db_enumerator e) db_enumerate_items(e) { fprintf(out, "[%d]\n", i); - for(j = 0; j < ITEM_FIELDS; j++) { + + for(cur = fields_list, j = 0; cur; cur = cur->next, j++) { if( database[e.item][j] != NULL && *database[e.item][j] ) fprintf(out, "%s=%s\n", - abook_fields[j].key, + cur->field->key, database[e.item][j] ); } + fputc('\n', out); i++; } @@ -199,18 +360,13 @@ save_database() goto out; } - if(list_is_empty()) { - fclose(out); - unlink(datafile); - ret = 1; - goto out; - } + if(!list_is_empty()) + /* + * Possibly should check if write_database failed. + * Currently it returns always zero. + */ + write_database(out, e); - /* - * Possibly should check if write_database failed. - * Currently it returns always zero. - */ - write_database(out, e); fclose(out); if(access(datafile, F_OK) == 0 && @@ -227,18 +383,9 @@ out: } static void -free_item(int item) +db_free_item(int item) { - free_list_item(database[item]); -} - -void -free_list_item(list_item item) -{ - int i; - - for(i=0; inext, i++) { + max_field_len = 0; + + switch(f->field->type) { + case FIELD_EMAILS: + max_field_len = MAX_EMAILSTR_LEN; + if(item[i] == NULL) + item[i] = xstrdup(""); + break; + case FIELD_LIST: + /* TODO quote string if it contains commas */ + break; + case FIELD_STRING: + max_field_len = MAX_FIELD_LEN; + break; + case FIELD_DATE: + break; + default: + assert(0); + } - for(i=0; i _MAX_FIELD_LEN(i) ) ) { + if(max_field_len && item[i] && + ((int)strlen(item[i]) > max_field_len)) { + /* truncate field */ tmp = item[i]; - item[i][_MAX_FIELD_LEN(i)-1] = 0; + item[i][max_field_len - 1] = 0; item[i] = xstrdup(item[i]); free(tmp); } + } } - static void adjust_list_capacity() { @@ -293,15 +459,20 @@ adjust_list_capacity() else return; - database = xrealloc(database, sizeof(list_item) * list_capacity); + if(database) + database = xrealloc(database,sizeof(list_item) * list_capacity); + else /* allocate memory _and_ initialize pointers to NULL */ + database = xmalloc0(sizeof(list_item) * list_capacity); + selected = xrealloc(selected, list_capacity); } int add_item2database(list_item item) { - if(item[NAME] == NULL || ! *item[NAME]) { - free_list_item(item); + /* 'name' field is mandatory */ + if((item[field_id(NAME)] == NULL) || ! *item[field_id(NAME)]) { + item_empty(item); return 1; } @@ -311,10 +482,13 @@ add_item2database(list_item item) validate_item(item); selected[LAST_ITEM] = 0; - itemcpy(database[LAST_ITEM], item); + + database[LAST_ITEM] = item_create(); + item_copy(database[LAST_ITEM], item); return 0; } + void remove_selected_items() @@ -329,11 +503,12 @@ remove_selected_items() for(j = LAST_ITEM; j >= 0; j--) { if(selected[j]) { - free_item(j); /* added for .4 data_s_ */ + db_free_item(j); /* added for .4 data_s_ */ for(i = j; i < LAST_ITEM; i++) { - itemcpy(database[i], database[i + 1]); + item_copy(database[i], database[i + 1]); selected[i] = selected[i + 1]; } + item_free(&database[LAST_ITEM]); items--; } } @@ -362,18 +537,17 @@ get_surname(char *s) static int surnamecmp(const void *i1, const void *i2) { - int ret; - list_item a,b; - char *s1, *s2; - - itemcpy(a, i1); - itemcpy(b, i2); + int ret, idx = field_id(NAME); + char *n1, *n2, *s1, *s2; - s1 = get_surname(a[NAME]); - s2 = get_surname(b[NAME]); + n1 = (*(list_item *)i1)[idx]; + n2 = (*(list_item *)i2)[idx]; + + s1 = get_surname(n1); + s2 = get_surname(n2); if( !(ret = safe_strcoll(s1, s2)) ) - ret = safe_strcoll(a[NAME], b[NAME]); + ret = safe_strcoll(n1, n2); free(s1); free(s2); @@ -386,45 +560,34 @@ static int sort_field = -1; static int namecmp(const void *i1, const void *i2) { - list_item a, b; + char *n1, *n2; - assert(sort_field >= 0 && sort_field <= LAST_FIELD); + assert(sort_field >= 0 && sort_field < fields_count); - itemcpy(a, i1); - itemcpy(b, i2); + n1 = (*(list_item *)i1)[sort_field]; + n2 = (*(list_item *)i2)[sort_field]; - return safe_strcoll(a[sort_field], b[sort_field]); -} - -static int -name2field(char *name) -{ - int i, ret = -1; - - for(i = 0; i < ITEM_FIELDS; i++) { - if(!strcasecmp(name, abook_fields[i].key)) { - ret = i; - break; - } - } - - return ret; + return safe_strcoll(n1, n2); } void -sort_by_field(int field) +sort_by_field(char *name) { + int field; + select_none(); - assert(field <= LAST_FIELD); + name = (name == NULL) ? opt_get_str(STR_SORT_FIELD) : name; + find_field_number(name, &field); if(field < 0) { - field = name2field(opt_get_str(STR_SORT_FIELD)); - if(field < 0) { + if(name == opt_get_str(STR_SORT_FIELD)) statusline_msg(_("Invalid field value defined " "in configuration")); - return; - } + else + statusline_msg(_("Invalid field value for sorting")); + + return; } sort_field = field; @@ -444,10 +607,11 @@ sort_surname() refresh_screen(); } +/* TODO implement a search based on more sophisticated patterns */ int find_item(char *str, int start, int search_fields[]) { - int i; + int i, id; char *findstr = NULL; char *tmp = NULL; int ret = -1; /* not found */ @@ -462,9 +626,11 @@ find_item(char *str, int start, int search_fields[]) e.item = start - 1; /* must be "real start" - 1 */ db_enumerate_items(e) { for(i = 0; search_fields[i] >= 0; i++) { - if(database[e.item][search_fields[i]] == NULL) + if((id = field_id(search_fields[i])) == -1) continue; - tmp = xstrdup(database[e.item][search_fields[i]]); + if(database[e.item][id] == NULL) + continue; + tmp = xstrdup(database[e.item][id]); if( tmp && strstr(strlower(tmp), findstr) ) { ret = e.item; goto out; @@ -479,7 +645,6 @@ out: return ret; } - int is_selected(int item) { @@ -492,6 +657,18 @@ is_valid_item(int item) return item <= LAST_ITEM && item >= 0; } +int +last_item() +{ + return LAST_ITEM; +} + +int +db_n_items() +{ + return items; +} + int real_db_enumerate_items(struct db_enumerator e) { @@ -504,7 +681,7 @@ real_db_enumerate_items(struct db_enumerator e) break; #endif case ENUM_SELECTED: - for(i = item; i < items; i++) { + for(i = item; i <= LAST_ITEM; i++) { if(is_selected(i)) { item = i; goto out; @@ -534,46 +711,142 @@ init_db_enumerator(int mode) return e; } -static int -assign_fieldname(const char *name, int i) + +list_item +item_create() { - char *s; + return xmalloc0(ITEM_SIZE); +} - assert(name); - assert(i >= 0 && i < ITEM_FIELDS); +void +item_free(list_item *item) +{ + assert(item); - if(strcasecmp(abook_fields[i].name, name)) { /* name differs */ - /* - * check if we are overwriting statically allocated default - */ - if(strcasecmp(abook_fields[i].name, abook_fields[i].key)) - xfree(abook_fields[i].name); + xfree(*item); +} + +void +item_empty(list_item item) +{ int i; + + assert(item); + + for(i = 0; i < fields_count; i++) + if(item[i]) + xfree(item[i]); + +} - s = xmalloc_inc(MAX_FIELDNAME_LEN, 1); - snprintf(s, MAX_FIELDNAME_LEN, "%s", name); - abook_fields[i].name = s; +void +item_copy(list_item dest, list_item src) +{ + memmove(dest, src, ITEM_SIZE); +} + +void +item_duplicate(list_item dest, list_item src) +{ + int i; + + for(i = 0; i < fields_count; i++) + dest[i] = src[i] ? xstrdup(src[i]) : NULL; +} + +/* + * Things like item[field_id(NICK)] should never be used, since besides NAME + * and EMAIL, none of the standard fields can be assumed to be existing. + * + * Prefer the functions item_fput(), item_fget(), db_fput() and db_fget() + * to access fields in items and database. + */ + +/* quick lookup by "standard" field number */ +inline int +field_id(int i) +{ + assert((i >= 0) && (i < ITEM_FIELDS)); + return standard_fields_indexed[i]; +} + +int +item_fput(list_item item, int i, char *val) +{ + int id = field_id(i); + + if(id != -1) { + item[id] = val; + return 1; } return 0; } +char * +item_fget(list_item item, int i) +{ + int id = field_id(i); + + if(id != -1) + return item[id]; + else + return NULL; +} + int -change_custom_field_name(const char *name, int n) +real_db_field_put(int item, int i, int std, char *val) { - int i; - char keyname[21]; + int id; - assert(name); + assert(database[item]); - snprintf(keyname, sizeof(keyname), "custom%d", n); + id = std ? field_id(i) : i; - for(i = CUSTOM_MIN; i <= CUSTOM_MAX; i++) { - if(!strcasecmp(abook_fields[i].key, keyname)) { - assign_fieldname(name, i); - return i; - } + if(id != -1) { + database[item][id] = val; + return 1; } - return -1; + return 0; +} + +char * +real_db_field_get(int item, int i, int std) +{ + int id; + + assert(database[item]); + + id = std ? field_id(i) : i; + + if(id != -1) + return database[item][id]; + else + return NULL; +} + +list_item +db_item_get(int i) +{ + return database[i]; +} + +/* Fetch addresses from all fields of FIELD_EMAILS type */ +/* Memory has to be freed by the caller */ +char * +db_email_get(int item) +{ + int i; + char *res; + abook_field_list *cur; + abook_list *emails = NULL; + + for(cur = fields_list, i = 0; cur; cur = cur->next, i++) + if(cur->field->type == FIELD_EMAILS && *database[item][i]) + abook_list_append(&emails, database[item][i]); + + res = abook_list_to_csv(emails); + abook_list_free(&emails); + return res ? res : xstrdup(""); } diff --git a/database.h b/database.h index 8722885..a81bd6e 100644 --- a/database.h +++ b/database.h @@ -1,14 +1,13 @@ #ifndef _DATABASE_H #define _DATABASE_H - -#define MAX_EMAILS 4 +#define MAX_LIST_ITEMS 9 #define MAX_EMAIL_LEN 80 -#define MAX_EMAILSTR_LEN (MAX_EMAILS*MAX_EMAIL_LEN + MAX_EMAILS + 1) +#define MAX_EMAILSTR_LEN (MAX_LIST_ITEMS * (MAX_EMAIL_LEN + 1) + 1) #define MAX_FIELD_LEN 81 enum { - NAME, + NAME = 0, /* important */ EMAIL, ADDRESS, ADDRESS2, @@ -23,27 +22,28 @@ enum { NICK, URL, NOTES, - CUSTOM1, - CUSTOM2, - CUSTOM3, - CUSTOM4, - CUSTOM5, + ANNIVERSARY, ITEM_FIELDS /* this is the last */ }; -#define LAST_FIELD (ITEM_FIELDS - 1) - -#define CUSTOM_MIN CUSTOM1 -#define CUSTOM_MAX CUSTOM5 +typedef struct { + char *key; + char *name; + int type; +} abook_field; -typedef char *list_item[ITEM_FIELDS]; +typedef struct abook_field_list_t { + abook_field *field; + struct abook_field_list_t *next; +} abook_field_list; -#define MAX_FIELDNAME_LEN 21 +typedef char **list_item; -struct abook_field { - char *name; - char *key; - int tab; +enum { + FIELD_STRING = 1, + FIELD_EMAILS, + FIELD_LIST, + FIELD_DATE, }; enum { @@ -56,48 +56,81 @@ struct db_enumerator { int mode; /* warning: read only */ }; -int find_field(const char *field); -int parse_database(FILE *in); -int write_database(FILE *out, struct db_enumerator e); -int load_database(char *filename); -int save_database(); -void close_database(); -int add_item2database(list_item item); -void free_list_item(list_item item); -void remove_selected_items(); -void sort_surname(); -void sort_by_field(int field); -char *get_surname(char *s); -int find_item(char *str, int start, int search_fields[]); -int is_selected(int item); -int is_valid_item(int item); - -int real_db_enumerate_items(struct db_enumerator e); -struct db_enumerator init_db_enumerator(int mode); -int change_custom_field_name(const char *name, int n); - -#define LAST_ITEM (items - 1) - -#define itemcpy(dest, src) memmove(dest, src, sizeof(list_item)) - -#define split_emailstr(item, emails) do {\ - int _i,_j,_k,len; \ - memset(&emails, 0, sizeof(emails) ); \ - len = strlen(database[item][EMAIL]); \ - for( _i=0,_j=0, _k=0; _i < len && _j < MAX_EMAILS; _i++ ) { \ - if( database[item][EMAIL][_i] ==',' ) { \ - _j++; \ - _k = 0; \ - } else \ - if( _k < MAX_EMAIL_LEN -1 ) \ - emails[_j][_k++] = database[item][EMAIL][_i]; \ - } \ -} while(0) - -#define have_multiple_emails(item) \ - strchr(database[item][EMAIL], ',') +/* + * Field operations + */ +inline int field_id(int i); +abook_field *find_standard_field(char *key, int do_declare); +abook_field *real_find_field(char *key, abook_field_list *list, int *nb); +#define find_field(key, list) real_find_field(key, list, NULL) +#define find_field_number(key, pt_nb) real_find_field(key, NULL, pt_nb) +#define find_declared_field(key) find_field(key,NULL) +void get_field_info(int i, char **key, char **name, int *type); +void add_field(abook_field_list **list, abook_field *f); +char *declare_new_field(char *key, char *name, char *type, int accept_standard); +void init_standard_fields(); + +/* + * Various database operations + */ +void prepare_database_internals(); +int parse_database(FILE *in); +int load_database(char *filename); +int write_database(FILE *out, struct db_enumerator e); +int save_database(); +void remove_selected_items(); +void sort_surname(); +void sort_by_field(char *field); +void close_database(); +int add_item2database(list_item item); +char *get_surname(char *s); +int find_item(char *str, int start, int search_fields[]); +int is_selected(int item); +int is_valid_item(int item); +int last_item(); +int db_n_items(); + +int real_db_enumerate_items(struct db_enumerator e); +struct db_enumerator init_db_enumerator(int mode); #define db_enumerate_items(e) \ while( -1 != (e.item = real_db_enumerate_items(e))) -#endif +/* + * item manipulation + */ +list_item item_create(); +void item_empty(list_item item); +void item_free(list_item *item); +void item_copy(list_item dest, list_item src); +void item_duplicate(list_item dest, list_item src); + +int item_fput(list_item item, int i, char *val); +char *item_fget(list_item item, int i); + +/* + * database field read + */ +char *real_db_field_get(int item, int i, int std); +#define db_fget(item, i) real_db_field_get(item, i, 1) +#define db_fget_byid(item, i) real_db_field_get(item, i, 0) +#define db_name_get(item) db_fget(item, NAME) +char *db_email_get(int item); /* memory has to be freed by the caller */ + +/* + * database field write + */ +int real_db_field_put(int item, int i, int std, char *val); +#define db_fput(item, i, val) \ + real_db_field_put(item, i, 1, val) +#define db_fput_byid(item, i, val) \ + real_db_field_put(item, i, 0, val) + +/* + * database item read + */ +list_item db_item_get(int i); + + +#endif /* _DATABASE_H */ + diff --git a/debian/changelog b/debian/changelog index da7ea20..f6c608d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,70 +1,83 @@ -abook (0.5.6-7) unstable; urgency=low - - * Build-Depend on autotools-dev, copy config.{guess,sub} before configure - run and remove them in clean target (closes: #535739) - * Updated to Standards-Version 3.8.2: Switched from findstring to filter and - add support parallel. - suggestion from policy. - * Switched the packaging licensing to BSD style. - * New patch: - - datafile-f-switch: Let --datafile also work through -f short option, - suggested by Joey Schulze - * New debconf translation: - - Traditional Chinese by Kanru Chen (closes: #508023) - - -- Gerfried Fuchs Tue, 09 Dec 2008 10:40:05 +0100 - -abook (0.5.6-6) unstable; urgency=low - - * Made copyright file more clear. - * Updated watch file to use special uscan hack for sourceforge. - * Updated Standards-Version to 3.8.0, added README.source file. +abook (0.6.0~pre2-2) unstable; urgency=low + + * Finally uploading to unstable. Making sure the changes are carried over, + especially: + - from 0.5.6-2: + - Swedish debconf translation, already mentioned in changelog but without + closes: #387518 + - Fixed quoting in mutt config snippet noticed by Georg Neis, thanks + (closes: #394532) + - from 0.5.6-3: + - Japanese debconf translation by Noritada Kobayashi (closes: #412998) + - from 0.5.6-4: + - Dutch debconf translation by Bart Cornelis (closes: #415513) + - Updated menu file to go with new menu policy. + - debian/rules: slightly cleanup. + - from 0.5.6-5: + - Add Homepage to source control stanca. + - Bump Standards-Version to 3.7.3, menu file was already updated. + - Russian debconf translation by Yuri Kozlov (closes: #451813) + - search_ctrl-d_segfault_fix included in the release already + (closes: #462145) + - from 0.5.6-6: + - Made copyright file more clear. + - Updated watch file to use special uscan hack for sourceforge. + - Updated Standards-Version to 3.8.0, added README.source file. + - New debconf translations: + - Spanish debconf translation by Carlos Eduardo Sotelo Pinto + (closes: #484848) + - Portuguese debconf translation, already mentioned in changelog but + without (closes: #489036). Actually the one mentioned was a newer + one than the one in the unstable branch. + - Fixed Catalan po file encoding. + - Use versioned Build-Depends on quilt for quilt.make usage. + - Also strip sections .comment and .note + - Add patch fix-manpage to escape hyphens where they should be minus + signs (adjusted it for the 0.6.0~pre2 release) + - from 0.5.6-7: + - Build-Depend on autotools-dev, copy config.{guess,sub} before configure + run and remove them in clean target (closes: #535739) + - Updated to Standards-Version 3.8.2: Switched from findstring to filter + and add support parallel. + suggestion from policy. + - Switched the packaging licensing to BSD style. + - New patch datafile-f-switch: Let --datafile also work through -f short + option, suggested by Joey Schulze + - Traditional Chinese debconf translation by Kanru Chen (closes: #508023) + * Relicense packaging under WTFPLv2. + * Bump Standards-Version to 3.9.3. * New debconf translations: - - Spanish by Carlos Eduardo Sotelo Pinto (closes: #484848) - - Portuguese by Miguel Figueiredo (closes: #489036) - * Fixed Catalan po file encoding. - * Put proper headers into the templates.pot file. - * Use versioned Build-Depends on quilt for quilt.make usage. - * Also strip sections .comment and .note - * Add patch fix-manpage to escape hyphens where they should be minus signs. + - Danish by Joe Hansen (closes: #626630) + - Polish by Michał Kułach (closes: #658602) + - Italian by Francesca Ciceri (closes: #658744) + * Add Vcs-* fields to debian/control. - -- Gerfried Fuchs Thu, 24 Jul 2008 15:17:28 +0200 + -- -abook (0.5.6-5) unstable; urgency=low +abook (0.6.0~pre2-1) experimental; urgency=low - * Add Homepage to source control stanca. - * Bump Standards-Version to 3.7.3, menu file was already updated. - * New debconf translation: Russian by Yuri Kozlov (closes: #451813) - * Pull search_ctrl-d_segfault_fix patch from upstream (closes: #462145) - - -- Gerfried Fuchs Thu, 24 Jan 2008 20:01:26 +0100 - -abook (0.5.6-4) unstable; urgency=low - - * New debconf translation: Dutch by Bart Cornelis (closes: #415513) - * Updated menu file to go with new menu policy. - * debian/rules: slightly cleanup. + * New upstream release - -- Gerfried Fuchs Thu, 31 May 2007 14:10:34 +0200 + -- Gerfried Fuchs Thu, 7 Sep 2006 10:29:20 -0500 -abook (0.5.6-3) unstable; urgency=low +abook (0.6.0~pre1-1) experimental; urgency=low - * Late l10n translation: Japanese by Noritada Kobayashi (closes: #412998) + * Upstream pre version of 0.6.0 release. + * new debconf translations: French by Pierre Machard (closes: #384681) - -- Gerfried Fuchs Sat, 3 Mar 2007 11:40:05 +0100 + -- Gerfried Fuchs Thu, 31 Aug 2006 07:26:11 -0500 -abook (0.5.6-2) unstable; urgency=low +abook (0.5.6+cvs1-1) experimental; urgency=low - * The "l10n R us" release. - * New debconf translations: Swedish by Daniel Nylander (closes: #387518), - Catalan by Jordà Polo (closes: #381362), French by Pierre Machard - (closes: #384681) - * Fixed typo in templates file and unfuzzied all translations that were - uptodate before (closes: #383473) - * Fixed quoting in mutt config snippet noticed by Georg Neis, thanks - (closes: #394532) + * CVS snapshot with flexible view, which resolves: + - small number of email addresses (closes: #333450) + * new debconf translations: Portuguese by Miguel Figueiredo, Català by + Jordà Polo (closes: #381362), Swedish by Daniel Nylander + * Fixed typo in template, noticed by Pierre Machard (closes: #383473) + * contrib files got deleted from upstream, so they are removed from the + Debian package, too. - -- Gerfried Fuchs Mon, 22 Jan 2007 22:02:22 +0100 + -- Gerfried Fuchs Mon, 21 Aug 2006 07:41:58 -0500 abook (0.5.6-1) unstable; urgency=low diff --git a/debian/config b/debian/config index 5a2484f..57fd21d 100644 --- a/debian/config +++ b/debian/config @@ -1,5 +1,7 @@ #!/bin/sh -e # config script for abook +# copyright 2012 by Gerfried Fuchs +# Licenced under WTFPLv2 action=$1 version=$2 diff --git a/debian/control b/debian/control index 639cca7..b9314dc 100644 --- a/debian/control +++ b/debian/control @@ -1,11 +1,13 @@ Source: abook Section: mail Priority: optional -Maintainer: Gerfried Fuchs -Standards-Version: 3.8.0 +Maintainer: Gerfried Fuchs +Standards-Version: 3.9.3 Build-Depends: libncursesw5-dev, libreadline5-dev | libreadline-dev, po-debconf, quilt (>= 0.40), autotools-dev Homepage: http://abook.sourceforge.net/ +Vcs-Browser: http://git.deb.at/w/pkg/abook.git +Vcs-Git: git://git.deb.at/g/pkg/abook.git Package: abook Architecture: any diff --git a/debian/copyright b/debian/copyright index 997d714..deb86de 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,6 +1,6 @@ This package was first debianized by Alan Ford on Sat, 18 Mar 2000 12:38:34 +0000. -It is now maintained by Gerfried Fuchs . +It is now maintained by Gerfried Fuchs . It was downloaded from http://abook.sourceforge.net/ @@ -25,10 +25,22 @@ Copyright: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -The debianization of the package is licensed under BSD style and -Copyright (c) 2003-2008 by Gerfried Fuchs . -See /usr/share/common-licenses/BSD for the complete text. - On Debian GNU/Linux systems, the complete text of the GNU General Public License version 2 can be found in `/usr/share/common-licenses/GPL-2', later versions can be found in the same directory. + +The debianization of the package is licensed under the WTFPLv2: + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2003-2012 Gerfried Fuchs + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/debian/patches/01_search_ctrl-d_segfault_fix b/debian/patches/01_search_ctrl-d_segfault_fix deleted file mode 100644 index 0c18f2c..0000000 --- a/debian/patches/01_search_ctrl-d_segfault_fix +++ /dev/null @@ -1,23 +0,0 @@ -Author: Cedric Duval vim:ft=diff: -Description: Don't let ctrl-d in search segfault abook (closes: #462145) - -Index: abook-0.5.6/ui.c -=================================================================== ---- abook-0.5.6.orig/ui.c -+++ abook-0.5.6/ui.c -@@ -569,9 +569,13 @@ ui_find(int next) - } else { - char *s; - s = ui_readline("/", findstr, MAX_FIELD_LEN - 1, 0); -- strncpy(findstr, s, MAX_FIELD_LEN); -- free(s); - refresh_screen(); -+ if(s == NULL) { -+ return; /* user cancelled (ctrl-G) */ -+ } else { -+ strncpy(findstr, s, MAX_FIELD_LEN); -+ free(s); -+ } - } - - if( (item = find_item(findstr, curitem + !!next, search_fields)) < 0 && diff --git a/debian/patches/02_fix-manpage b/debian/patches/02_fix-manpage index 45b4345..e89ce8c 100644 --- a/debian/patches/02_fix-manpage +++ b/debian/patches/02_fix-manpage @@ -1,13 +1,13 @@ -Author: Gerfried Fuchs vim:ft=diff: +Author: Gerfried Fuchs vim:ft=diff: Description: Escape hyphens in manpage where they mean the minus sign -Index: abook-0.5.6/abook.1 +Index: b/abook.1 =================================================================== ---- abook-0.5.6.orig/abook.1 -+++ abook-0.5.6/abook.1 -@@ -80,11 +80,11 @@ The following \fIoutputformats\fR are su +--- a/abook.1 ++++ b/abook.1 +@@ -82,11 +82,11 @@ The following \fIoutputformats\fR are su .br - - \fBwl\fP Wanderlust address book + - \fBbsdcal\fP BSD calendar .TP -\fB\-\-add-email\fP +\fB\-\-add\-email\fP @@ -20,34 +20,16 @@ Index: abook-0.5.6/abook.1 .TP \fB\-\-formats\fP List available formats. -Index: abook-0.5.6/abookrc.5 +Index: b/abookrc.5 =================================================================== ---- abook-0.5.6.orig/abookrc.5 -+++ abook-0.5.6/abookrc.5 -@@ -47,7 +47,7 @@ Defines the field to display in the extr - .br - \fIfield\fP can be any of the following: - .br ---1 disabled -+\-1 disabled - .br - phone Home Phone - .br -@@ -125,7 +125,7 @@ set emailpos=25 - # Field to be used in the extra column - set extra_column=phone - # frequently used values: --# -1 disabled -+# \-1 disabled - # phone Home Phone - # workphone Work Phone - # fax Fax -@@ -134,7 +134,7 @@ set extra_column=phone - # url URL - - # --set extra_alternative=-1 -+set extra_alternative=\-1 - - # Screen column for the extra field to start - set extrapos=65 +--- a/abookrc.5 ++++ b/abookrc.5 +@@ -90,7 +90,7 @@ Defines the way entries are displayed in + \fI{name:22}\fP + displays the \fIname\fP field with a maximal width of 22 characters. + .TP +-\fI{phone:-13|workphone|mobile}\fP ++\fI{phone:\-13|workphone|mobile}\fP + displays (right aligned within a width of 13 characters), either the \fIphone\fP, \fIworkphone\fP or \fImobile\fP field, whichever being the first to be non-empty. + .RE + .IP diff --git a/debian/patches/03_datafile-f-switch b/debian/patches/03_datafile-f-switch index 845788b..eb2c5b1 100644 --- a/debian/patches/03_datafile-f-switch +++ b/debian/patches/03_datafile-f-switch @@ -1,11 +1,11 @@ -Author: Gerfried Fuchs vim:ft=diff: +Author: Gerfried Fuchs vim:ft=diff: Description: Let --datafile also work through -f short option -Index: abook-0.5.6/abook.c +Index: b/abook.c =================================================================== ---- abook-0.5.6.orig/abook.c -+++ abook-0.5.6/abook.c -@@ -324,7 +324,7 @@ parse_command_line(int argc, char **argv +--- a/abook.c ++++ b/abook.c +@@ -331,7 +331,7 @@ parse_command_line(int argc, char **argv { 0, 0, 0, 0 } }; diff --git a/debian/patches/series b/debian/patches/series index 31fd7b9..c89c5ae 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,3 +1,2 @@ -01_search_ctrl-d_segfault_fix 02_fix-manpage 03_datafile-f-switch diff --git a/debian/po/ca.po b/debian/po/ca.po index 24cc768..f474ce3 100644 --- a/debian/po/ca.po +++ b/debian/po/ca.po @@ -9,10 +9,11 @@ msgid "" msgstr "" "Project-Id-Version: 2.1.1\n" "Report-Msgid-Bugs-To: abook@packages.debian.org\n" -"POT-Creation-Date: 2007-01-22 23:01+0100\n" -"PO-Revision-Date: 2008-07-07 21:47+0200\n" +"POT-Creation-Date: 2006-08-18 10:38-0500\n" +"PO-Revision-Date: 2006-08-18 10:42-0500\n" "Last-Translator: Jordà Polo \n" "Language-Team: Català \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/debian/po/cs.po b/debian/po/cs.po index 2c03099..05d1c23 100644 --- a/debian/po/cs.po +++ b/debian/po/cs.po @@ -7,10 +7,11 @@ msgid "" msgstr "" "Project-Id-Version: abook\n" "Report-Msgid-Bugs-To: abook@packages.debian.org\n" -"POT-Creation-Date: 2007-01-22 23:01+0100\n" -"PO-Revision-Date: 2007-01-22 23:00+0100\n" +"POT-Creation-Date: 2006-08-18 10:38-0500\n" +"PO-Revision-Date: 2006-08-18 10:42-0500\n" "Last-Translator: Miroslav Kure \n" "Language-Team: Czech \n" +"Language: cs\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/debian/po/da.po b/debian/po/da.po new file mode 100644 index 0000000..388cc28 --- /dev/null +++ b/debian/po/da.po @@ -0,0 +1,38 @@ +# Danish translation abook. +# Copyright (C) 2011 Gerfried Fuchs & nedenstÃ¥ende oversættere. +# This file is distributed under the same license as the abook package. +# Joe Hansen (joedalton2@yahoo.dk), 2011. +# +msgid "" +msgstr "" +"Project-Id-Version: abook\n" +"Report-Msgid-Bugs-To: abook@packages.debian.org\n" +"POT-Creation-Date: 2006-08-18 10:38-0500\n" +"PO-Revision-Date: 2011-05-13 18:30+01:00\n" +"Last-Translator: Joe Hansen \n" +"Language-Team: Danish \n" +"Language: da\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "Do you want to enable abook system wide for mutt?" +msgstr "Ønsker du at aktivere abook pÃ¥ hele systemet for mutt?" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"abook offers the possibility to be used as query backend from within mutt. " +"If you acknowledge this question the package will create an /etc/Muttrc.d/" +"abook.rc file that enables querying the abook database and adding mail " +"addresses to abook with pressing \"A\" from pager mode." +msgstr "" +"abook tilbyder muligheden for at blive brugt som forespørgelsesmotor inden " +"fra mutt. Hvis du accepterer dette spørgsmÃ¥l, vil pakken oprette en /etc/" +"Muttrc.d/abook-rc-fil, som aktiverer forespørgsler til abooks database og " +"tilføjelse af postadresser til abook med et tryk pÃ¥ »A« fra " +"tekstvisertilstanden." diff --git a/debian/po/de.po b/debian/po/de.po index a0b6443..a69f6f9 100644 --- a/debian/po/de.po +++ b/debian/po/de.po @@ -16,9 +16,10 @@ msgstr "" "Project-Id-Version: abook 0.5.0\n" "Report-Msgid-Bugs-To: abook@packages.debian.org\n" "POT-Creation-Date: 2006-08-18 10:38-0500\n" -"PO-Revision-Date: 2008-07-07 22:03+0200\n" -"Last-Translator: Gerfried Fuchs \n" +"PO-Revision-Date: 2006-08-18 10:42-0500\n" +"Last-Translator: Gerfried Fuchs \n" "Language-Team: German \n" +"Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=ISO-8859-15\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/debian/po/es.po b/debian/po/es.po index ff73c5a..57b4550 100644 --- a/debian/po/es.po +++ b/debian/po/es.po @@ -9,7 +9,7 @@ # Traductores, si no estan familiarizados con el formato PO, merece la # pena leer la documentación de gettext, especialmente las secciones # dedicadas a este formato, por ejemplo ejecutando -# +# # info -n '(gettext)PO Files' # info -n '(gettext)Header Entry' # @@ -17,7 +17,7 @@ # http://www.debian.org/intl/spanish/ # especialmente las notas y normas de traducción en # http://www.debian.org/intl/spanish/notas -# +# # - La guía de traducción de po's de debconof # /usr/share/doc/po-debconf/README-trans # o @@ -32,10 +32,11 @@ msgid "" msgstr "" "Project-Id-Version: abook 0.5.6-5\n" "Report-Msgid-Bugs-To: abook@packages.debian.org\n" -"POT-Creation-Date: 2007-01-22 23:01+0100\n" +"POT-Creation-Date: 2006-08-18 10:38-0500\n" "PO-Revision-Date: 2008-06-02 15:27-0500\n" "Last-Translator: Carlos Eduardo Sotelo Pinto \n" "Language-Team: Spanish \n" +"Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -54,8 +55,8 @@ msgid "" "If you acknowledge this question the package will create an /etc/Muttrc.d/" "abook.rc file that enables querying the abook database and adding mail " "addresses to abook with pressing \"A\" from pager mode." -msgstr "abook brinda la posibilidad de utilizarse como origen de consultas " -"desde mutt. " -"Si acepta esta pregunta el paquete creará un fichero «/etc/Muttrc.d/abook.rc» " -"que habilita las consultas a la base de datos de abook y agrega " -"la dirección de correo a abook presionando \"A\" desde el modo paginador" +msgstr "" +"abook brinda la posibilidad de utilizarse como origen de consultas desde " +"mutt. Si acepta esta pregunta el paquete creará un fichero «/etc/Muttrc.d/" +"abook.rc» que habilita las consultas a la base de datos de abook y agrega la " +"dirección de correo a abook presionando \"A\" desde el modo paginador" diff --git a/debian/po/fr.po b/debian/po/fr.po index 29f83ae..d7163f8 100644 --- a/debian/po/fr.po +++ b/debian/po/fr.po @@ -6,10 +6,11 @@ msgid "" msgstr "" "Project-Id-Version: abook\n" "Report-Msgid-Bugs-To: abook@packages.debian.org\n" -"POT-Creation-Date: 2007-01-22 23:01+0100\n" -"PO-Revision-Date: 2007-01-22 23:00+0100\n" +"POT-Creation-Date: 2006-08-18 10:38-0500\n" +"PO-Revision-Date: 2006-08-31 07:24-0500\n" "Last-Translator: Pierre Machard \n" "Language-Team: Debian l10n French \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=ISO-8859-15\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/debian/po/hu.po b/debian/po/hu.po index 2893d1a..87cc5ce 100644 --- a/debian/po/hu.po +++ b/debian/po/hu.po @@ -2,10 +2,11 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: abook@packages.debian.org\n" -"POT-Creation-Date: 2007-01-22 23:01+0100\n" -"PO-Revision-Date: 2007-01-22 23:01+0100\n" +"POT-Creation-Date: 2006-08-18 10:38-0500\n" +"PO-Revision-Date: 2006-08-18 10:42-0500\n" "Last-Translator: SZERVÑC Attila \n" "Language-Team: Hungarian \n" +"Language: hu\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/debian/po/it.po b/debian/po/it.po new file mode 100644 index 0000000..9473558 --- /dev/null +++ b/debian/po/it.po @@ -0,0 +1,37 @@ +# po-debconf translation for abook. +# Copyright (C) 2006 Gerfried Fuchs +# This file is distributed under the same license as the abook package. +# Francesca Ciceri , 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: abook\n" +"Report-Msgid-Bugs-To: abook@packages.debian.org\n" +"POT-Creation-Date: 2006-08-18 10:38-0500\n" +"PO-Revision-Date: 2012-02-05 19:08+0100\n" +"Last-Translator: Francesca Ciceri \n" +"Language-Team: Italian \n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "Do you want to enable abook system wide for mutt?" +msgstr "Si desidera abilitare abook per mutt globalmente?" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"abook offers the possibility to be used as query backend from within mutt. " +"If you acknowledge this question the package will create an /etc/Muttrc.d/" +"abook.rc file that enables querying the abook database and adding mail " +"addresses to abook with pressing \"A\" from pager mode." +msgstr "" +"abook offre la possibilità di essere usato come backend per le query in " +"mutt. Se si acconsente, il pacchetto creerà un file /etc/Muttrc.d/abook.rc " +"che abiliti l'interrogazione del database di abook e l'aggiunta di indirizzi " +"email ad abook premendo il tasto \"A\" dal paginatore." diff --git a/debian/po/ja.po b/debian/po/ja.po index f8580c4..a11b03e 100644 --- a/debian/po/ja.po +++ b/debian/po/ja.po @@ -6,10 +6,11 @@ msgid "" msgstr "" "Project-Id-Version: abook (debconf) 0.5.6-2\n" "Report-Msgid-Bugs-To: abook@packages.debian.org\n" -"POT-Creation-Date: 2007-01-22 23:01+0100\n" +"POT-Creation-Date: 2006-08-18 10:38-0500\n" "PO-Revision-Date: 2007-03-01 16:03+0900\n" "Last-Translator: Noritada Kobayashi \n" "Language-Team: Japanese \n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/debian/po/nl.po b/debian/po/nl.po index baa5a42..c7d39dd 100644 --- a/debian/po/nl.po +++ b/debian/po/nl.po @@ -7,10 +7,11 @@ msgid "" msgstr "" "Project-Id-Version: abook\n" "Report-Msgid-Bugs-To: abook@packages.debian.org\n" -"POT-Creation-Date: 2007-01-22 23:01+0100\n" +"POT-Creation-Date: 2006-08-18 10:38-0500\n" "PO-Revision-Date: 2007-03-09 18:35+0100\n" "Last-Translator: Bart Cornelis \n" "Language-Team: debian-l10n-dutch \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -25,6 +26,14 @@ msgstr "Wilt u abook voor mutt systeemwijd activeren?" #. Type: boolean #. Description #: ../templates:1001 -msgid "abook offers the possibility to be used as query backend from within mutt. If you acknowledge this question the package will create an /etc/Muttrc.d/abook.rc file that enables querying the abook database and adding mail addresses to abook with pressing \"A\" from pager mode." -msgstr "Mutt kan abook als een 'bevraag-backend' gebruiken. Als u wilt dat dit pakket een '/etc/Muttrc.d/abook.rc '-bestand aanmaakt dient u hier positief te antwoorden. Het aanmaken van dit bestand activeert het bevragen van de abook-database, en het toevoegen van e-mailadressen aan de abook-databse (door 'A' te drukken in 'pager'-modus)." - +msgid "" +"abook offers the possibility to be used as query backend from within mutt. " +"If you acknowledge this question the package will create an /etc/Muttrc.d/" +"abook.rc file that enables querying the abook database and adding mail " +"addresses to abook with pressing \"A\" from pager mode." +msgstr "" +"Mutt kan abook als een 'bevraag-backend' gebruiken. Als u wilt dat dit " +"pakket een '/etc/Muttrc.d/abook.rc '-bestand aanmaakt dient u hier positief " +"te antwoorden. Het aanmaken van dit bestand activeert het bevragen van de " +"abook-database, en het toevoegen van e-mailadressen aan de abook-databse " +"(door 'A' te drukken in 'pager'-modus)." diff --git a/debian/po/pl.po b/debian/po/pl.po new file mode 100644 index 0000000..a03bd65 --- /dev/null +++ b/debian/po/pl.po @@ -0,0 +1,40 @@ +# po-debconf translation for abook. +# Copyright (C) 2006 Gerfried Fuchs +# This file is distributed under the same license as the abook package. +# +# Michał Kułach , 2012. +msgid "" +msgstr "" +"Project-Id-Version: abook VERSION\n" +"Report-Msgid-Bugs-To: abook@packages.debian.org\n" +"POT-Creation-Date: 2006-08-18 10:38-0500\n" +"PO-Revision-Date: 2012-02-04 11:30+0100\n" +"Last-Translator: Michał Kułach \n" +"Language-Team: Polish \n" +"Language: pl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.2\n" +"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " +"|| n%100>=20) ? 1 : 2);\n" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "Do you want to enable abook system wide for mutt?" +msgstr "Czy pozwolić na współpracę abook z mutt na poziomie systemu?" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"abook offers the possibility to be used as query backend from within mutt. " +"If you acknowledge this question the package will create an /etc/Muttrc.d/" +"abook.rc file that enables querying the abook database and adding mail " +"addresses to abook with pressing \"A\" from pager mode." +msgstr "" +"Program abook może być używany jako backend z poziomu mutta. Jeśli zostanie " +"wybrana odpowiedź \"tak\", pakiet utworzy plik /etc/Muttrc.d/abook.rc, który " +"umożliwi odpytywanie bazy danych abook i dodawanie adresów poczty " +"elektronicznej do abook przez wciśnięcie \"A\" z trybu pagera." diff --git a/debian/po/pt.po b/debian/po/pt.po index 23c0fc1..f4dd6c7 100644 --- a/debian/po/pt.po +++ b/debian/po/pt.po @@ -6,10 +6,11 @@ msgid "" msgstr "" "Project-Id-Version: abook\n" "Report-Msgid-Bugs-To: abook@packages.debian.org\n" -"POT-Creation-Date: 2007-01-22 23:01+0100\n" +"POT-Creation-Date: 2006-08-18 10:38-0500\n" "PO-Revision-Date: 2008-07-02 23:05+0100\n" "Last-Translator: Miguel Figueiredo \n" "Language-Team: Portuguese \n" +"Language: pt\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/debian/po/pt_BR.po b/debian/po/pt_BR.po index a4c73b2..6ffba00 100644 --- a/debian/po/pt_BR.po +++ b/debian/po/pt_BR.po @@ -7,10 +7,11 @@ msgid "" msgstr "" "Project-Id-Version: abook\n" "Report-Msgid-Bugs-To: abook@packages.debian.org\n" -"POT-Creation-Date: 2007-01-22 23:01+0100\n" -"PO-Revision-Date: 2007-01-22 23:01+0100\n" +"POT-Creation-Date: 2006-08-18 10:38-0500\n" +"PO-Revision-Date: 2006-08-18 10:42-0500\n" "Last-Translator: Felipe Augusto van de Wiel (faw) \n" "Language-Team: l10n portuguese \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/debian/po/ro.po b/debian/po/ro.po index 017ee35..502dac2 100644 --- a/debian/po/ro.po +++ b/debian/po/ro.po @@ -6,10 +6,11 @@ msgid "" msgstr "" "Project-Id-Version: abook\n" "Report-Msgid-Bugs-To: abook@packages.debian.org\n" -"POT-Creation-Date: 2007-01-22 23:01+0100\n" -"PO-Revision-Date: 2007-01-22 23:01+0100\n" +"POT-Creation-Date: 2006-08-18 10:38-0500\n" +"PO-Revision-Date: 2006-08-18 10:42-0500\n" "Last-Translator: Eddy Petrişor \n" "Language-Team: Romanian \n" +"Language: ro\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/debian/po/ru.po b/debian/po/ru.po index 182d0fa..79d5289 100644 --- a/debian/po/ru.po +++ b/debian/po/ru.po @@ -7,15 +7,17 @@ msgid "" msgstr "" "Project-Id-Version: 0.5.6-4\n" "Report-Msgid-Bugs-To: abook@packages.debian.org\n" -"POT-Creation-Date: 2007-01-22 23:01+0100\n" +"POT-Creation-Date: 2006-08-18 10:38-0500\n" "PO-Revision-Date: 2007-11-18 21:39+0300\n" "Last-Translator: Yuri Kozlov \n" "Language-Team: Russian \n" +"Language: ru\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: KBabel 1.11.4\n" -"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" #. Type: boolean #. Description @@ -32,9 +34,8 @@ msgid "" "abook.rc file that enables querying the abook database and adding mail " "addresses to abook with pressing \"A\" from pager mode." msgstr "" -"abook можно использовать как сервер запросов из mutt. " -"Если вы ответите утвердительно, то будет создан файл " -"/etc/Muttrc.d/abook.rc, настройки которого активируют возможность " -"запросов к базе данных abook и настраивают добавление почтовых адресов " -"в abook по нажатию клавиши \"A\" из режима просмотра письма." - +"abook можно использовать как сервер запросов из mutt. Если вы ответите " +"утвердительно, то будет создан файл /etc/Muttrc.d/abook.rc, настройки " +"которого активируют возможность запросов к базе данных abook и настраивают " +"добавление почтовых адресов в abook по нажатию клавиши \"A\" из режима " +"просмотра письма." diff --git a/debian/po/sv.po b/debian/po/sv.po index 6bcd070..47b15c6 100644 --- a/debian/po/sv.po +++ b/debian/po/sv.po @@ -1,16 +1,17 @@ -# SOME DESCRIPTIVE TITLE. +# Swedish translation for abook (debconf). # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the abook package. -# FIRST AUTHOR , YEAR. +# Daniel Nylander , 2006. # msgid "" msgstr "" -"Project-Id-Version: abook 0.5.6-1\n" +"Project-Id-Version: abook\n" "Report-Msgid-Bugs-To: abook@packages.debian.org\n" -"POT-Creation-Date: 2007-01-22 23:01+0100\n" -"PO-Revision-Date: 2007-01-22 23:01+0100\n" +"POT-Creation-Date: 2006-08-18 10:38-0500\n" +"PO-Revision-Date: 2006-08-18 10:42-0500\n" "Last-Translator: Daniel Nylander \n" "Language-Team: Swedish \n" +"Language: sv\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=iso-8859-1\n" "Content-Transfer-Encoding: 8bit\n" @@ -30,7 +31,7 @@ msgid "" "abook.rc file that enables querying the abook database and adding mail " "addresses to abook with pressing \"A\" from pager mode." msgstr "" -"Abook erbjuder möjligheten att användas som en frågebakände innefrån mutt. " -"Om du bekräftar denna fråga kommer paketet att skapa en fil kallad /etc/" -"Muttrc.d/abook.rc som tillåter frågor mot abook-databasen och att lägga till " -"e-postadresser till abook genom att trycka på \"A\" från visningsläget." +"abook erbjuder möjligheten att användas som bakända för frågor i mutt. Om du " +"bekräftar denna fråga kommer paketet att skapa en fil kallad /etc/Muttrc.d/" +"abook.rc som aktiverar frågor mot abooks databas och lägger till e-" +"postadresser till abook när du trycker \"A\" från visningsläget." diff --git a/debian/po/templates.pot b/debian/po/templates.pot index 50391d1..e6d95f3 100644 --- a/debian/po/templates.pot +++ b/debian/po/templates.pot @@ -1,5 +1,5 @@ # po-debconf translation for abook. -# Copyright (C) 2006 Gerfried Fuchs +# Copyright (C) 2006 Gerfried Fuchs # This file is distributed under the same license as the abook package. # FIRST AUTHOR , YEAR. # diff --git a/debian/po/vi.po b/debian/po/vi.po index f88d8e5..09aa9c8 100644 --- a/debian/po/vi.po +++ b/debian/po/vi.po @@ -6,10 +6,11 @@ msgid "" msgstr "" "Project-Id-Version: abook\n" "Report-Msgid-Bugs-To: abook@packages.debian.org\n" -"POT-Creation-Date: 2007-01-22 23:01+0100\n" -"PO-Revision-Date: 2007-01-22 23:01+0100\n" +"POT-Creation-Date: 2006-08-18 10:38-0500\n" +"PO-Revision-Date: 2006-08-18 10:42-0500\n" "Last-Translator: Clytie Siddall \n" "Language-Team: Vietnamese \n" +"Language: vi\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/debian/po/zh_TW.po b/debian/po/zh_TW.po index 11247f6..1ba4775 100644 --- a/debian/po/zh_TW.po +++ b/debian/po/zh_TW.po @@ -1,5 +1,5 @@ # po-debconf translation for abook. -# Copyright (C) 2006 Gerfried Fuchs +# Copyright (C) 2006 Gerfried Fuchs # This file is distributed under the same license as the abook package. # Kanru Chen , 2008. # @@ -12,6 +12,7 @@ msgstr "" "Last-Translator: Kanru Chen \n" "Language-Team: Debian-user in Chinese [Big5] \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/debian/postinst b/debian/postinst index c22ed21..f856309 100644 --- a/debian/postinst +++ b/debian/postinst @@ -1,7 +1,7 @@ #!/bin/sh -e # postinst for abook -# copyright 2003-2009 by Gerfried Fuchs -# Licenced under BSD style +# copyright 2003-2012 by Gerfried Fuchs +# Licenced under WTFPLv2 # Source debconf library. if [ -e /usr/share/debconf/confmodule ]; then diff --git a/debian/postrm b/debian/postrm index 87fe8a9..fc75243 100644 --- a/debian/postrm +++ b/debian/postrm @@ -1,7 +1,7 @@ #!/bin/sh -e # postrm for abook -# copyright 2003-2009 by Gerfried Fuchs -# Licenced under BSD style +# copyright 2003-2012 by Gerfried Fuchs +# Licenced under WTFPLv2 if [ -x "`which update-menus 2>/dev/null`" ]; then update-menus diff --git a/debian/rules b/debian/rules index 96f875a..02a2a7c 100755 --- a/debian/rules +++ b/debian/rules @@ -1,7 +1,7 @@ #!/usr/bin/make -f # debian/rules for abook -# copyright 2003-2009 by Gerfried Fuchs -# Licenced under BSD style +# copyright 2003-2012 by Gerfried Fuchs +# Licenced under WTFPLv2 PKG = abook TMP = $(CURDIR)/debian/$(PKG) @@ -58,8 +58,7 @@ install: build $(checkroot) -rm -rf $(TMP) $(INSTALL_DIR) $(TMP) - cd $(TMP) && $(INSTALL_DIR) usr/share/doc/$(PKG)/examples \ - usr/share/doc/$(PKG)/contrib + cd $(TMP) && $(INSTALL_DIR) usr/share/doc/$(PKG)/examples $(MAKE) prefix=$(TMP)/usr install INSTALL_PROGRAM="$(INSTALL_PROGRAM)" test "$(STRIP)" != true || strip \ --remove-section=.comment --remove-section=.note \ @@ -67,13 +66,10 @@ install: build $(INSTALL_FILE) ChangeLog $(TMP)/usr/share/doc/$(PKG)/changelog $(INSTALL_FILE) ANNOUNCE AUTHORS BUGS FAQ README THANKS TODO \ $(TMP)/usr/share/doc/$(PKG) - $(INSTALL_FILE) sample.abookrc contrib/mail2abook.py \ - contrib/vcard2abook.pl $(TMP)/usr/share/doc/$(PKG)/examples - $(INSTALL_FILE) contrib/abook+vim/README contrib/abook+vim/mail.vim \ - $(TMP)/usr/share/doc/$(PKG)/contrib + $(INSTALL_FILE) sample.abookrc \ + $(TMP)/usr/share/doc/$(PKG)/examples cd $(TMP)/usr/share && gzip -9 man/man1/abook.1 man/man5/abookrc.5 \ - doc/$(PKG)/examples/mail2abook.py doc/$(PKG)/changelog \ - doc/$(PKG)/contrib/mail.vim + doc/$(PKG)/changelog # Build architecture-independent files here. diff --git a/edit.c b/edit.c index aed24c6..b9138e6 100644 --- a/edit.c +++ b/edit.c @@ -1,6 +1,6 @@ /* - * $Id: edit.c,v 1.43 2005/10/20 13:59:30 cduval Exp $ + * $Id: edit.c,v 1.55 2006/09/06 02:46:44 cduval Exp $ * * by JH * @@ -9,6 +9,7 @@ #include #include +#include #include #include "abook_curses.h" #include "ui.h" @@ -18,6 +19,7 @@ #include "list.h" #include "edit.h" #include "misc.h" +#include "views.h" #include "xmalloc.h" #ifdef HAVE_CONFIG_H # include "config.h" @@ -27,34 +29,26 @@ * some extern variables */ -extern struct abook_field abook_fields[]; - -extern list_item *database; -extern int curitem; -extern int items; +extern int views_count; WINDOW *editw; + static void editor_tab(const int tab) { int i, j; int x_pos = 2; /* current x pos */ - static char *tab_names[] = { - N_("CONTACT"), - N_("ADDRESS"), - N_(" PHONE "), - N_(" OTHER "), - N_("CUSTOM ") - }; + char *tab_name; mvwhline(editw, TABLINE + 1, 0, UI_HLINE_CHAR, EDITW_COLS); - for(i = 0; i < TABS; i++) { - int width = strwidth(gettext(tab_names[i])) + 5; + for(i = 0; i < views_count; i++) { + view_info(i, &tab_name, NULL); + int width = strwidth(tab_name) + 5; if(x_pos + width + 1 > EDITW_COLS) { - statusline_msg(_("Tab name too wide for screen")); + statusline_addstr(_("Tab name too wide for screen")); break; } @@ -63,7 +57,7 @@ editor_tab(const int tab) mvwaddch(editw, TABLINE, x_pos, UI_ULCORNER_CHAR); mvwaddch(editw, TABLINE, x_pos + 1, UI_LBOXLINE_CHAR); - mvwaddstr(editw, TABLINE, x_pos + 2, gettext(tab_names[i])); + mvwaddstr(editw, TABLINE, x_pos + 2, tab_name); mvwaddch(editw, TABLINE, x_pos + width - 3, UI_RBOXLINE_CHAR); mvwaddch(editw, TABLINE, x_pos + width - 2, UI_URCORNER_CHAR); @@ -82,36 +76,36 @@ editor_tab(const int tab) void get_first_email(char *str, int item) { - char *tmp; + char *tmp, *emails = db_email_get(item); - if(database[item][EMAIL] == NULL) { + if(!*emails) { *str = 0; return; } - strncpy(str, database[item][EMAIL], MAX_EMAIL_LEN); + strncpy(str, emails, MAX_EMAIL_LEN); + free(emails); if( (tmp = strchr(str, ',')) ) *tmp = 0; else - str[MAX_EMAIL_LEN-1] = 0; + str[MAX_EMAIL_LEN - 1] = 0; } +/* This only rolls emails from the 'email' field, not emails from any + * field of type FIELD_EMAILS. + * TODO: expand to ask for which field to roll if several are present? */ static void -roll_emails(int item) +roll_emails(int item, enum rotate_dir dir) { - char tmp[MAX_EMAILSTR_LEN]; - char *p; - - strcpy(tmp, database[item][EMAIL]); + abook_list *emails = csv_to_abook_list(db_fget(item, EMAIL)); - if( !(p = strchr(tmp, ',')) ) + if(!emails) return; - else - *p = 0; - strcpy(database[item][EMAIL], p+1); - strcat(database[item][EMAIL], ","); - strcat(database[item][EMAIL], tmp); + free(db_fget(item, EMAIL)); + abook_list_rotate(&emails, dir); + db_fput(item, EMAIL, abook_list_to_csv(emails)); + abook_list_free(&emails); } static void @@ -119,6 +113,7 @@ init_editor() { clear(); editw = newwin(EDITW_LINES, EDITW_COLS, EDITW_TOP, EDITW_X); + notimeout(editw, TRUE); /* handling of escape key */ refresh_statusline(); } @@ -132,47 +127,39 @@ enum { static int edit_undo(int item, int mode) { - int i; - static list_item *backup = NULL; + static list_item backup = NULL; static int backed_up_item = -1; switch(mode) { case CLEAR_UNDO: if(backup) { - free_list_item(backup[0]); - xfree(backup); + item_empty(backup); + item_free(&backup); } break; case BACKUP_ITEM: if(backup) { - free_list_item(backup[0]); - xfree(backup); + item_empty(backup); + item_free(&backup); } - backup = xmalloc(sizeof(list_item)); - for(i = 0; i < ITEM_FIELDS; i++) - if(database[item][i] == NULL) - backup[0][i] = NULL; - else - backup[0][i] = - xstrdup(database[item][i]); + backup = item_create(); + item_duplicate(backup, db_item_get(item)); backed_up_item = item; break; case RESTORE_ITEM: if(backup) { - free_list_item(database[backed_up_item]); - itemcpy(database[backed_up_item], backup[0]); - xfree(backup); + item_empty(db_item_get(backed_up_item)); + item_copy(db_item_get(backed_up_item), backup); + item_free(&backup); return backed_up_item; } break; default: assert(0); } - return item; } - static void close_editor() { @@ -192,15 +179,14 @@ print_editor_header(int item) get_first_email(email, item); - if(*database[item][EMAIL]) + if(*email) snprintf(header, EDITW_COLS, "%s <%s>", - database[item][NAME], + db_name_get(item), email); else - snprintf(header, EDITW_COLS, "%s", database[item][NAME]); + snprintf(header, EDITW_COLS, "%s", db_name_get(item)); - mvwaddstr(editw, 0, (EDITW_COLS - strwidth(header)) / 2, - header); + mvwaddstr(editw, 0, (EDITW_COLS - strwidth(header)) / 2, header); free(header); } @@ -208,29 +194,14 @@ print_editor_header(int item) static void editor_print_data(int tab, int item) { - int i, j; + int j = 1, nb; int y, x; + abook_field_list *cur; + char *str; - for(i = 0, j = 1; i < ITEM_FIELDS; i++) { - if(abook_fields[i].tab != tab) - continue; + view_info(tab, NULL, &cur); - if(i == EMAIL) { /* special field */ - int k; - char emails[MAX_EMAILS][MAX_EMAIL_LEN]; - split_emailstr(item, emails); - getyx(editw, y, x); - mvwaddstr(editw, y+1, FIELDS_START_X, - _("E-mail addresses:")); - for(k = 0; k < MAX_EMAILS; k++) { - getyx(editw, y, x); - mvwprintw(editw, y+1, FIELDS_START_X, - "%c -", '2' + k); - mvwprintw(editw, y +1, TAB_COLON_POS, - ": %s", emails[k]); - } - continue; - } + for(; cur; cur = cur->next) { if(j > 1) { getyx(editw, y, x); @@ -238,12 +209,62 @@ editor_print_data(int tab, int item) } else y = FIELDS_START_Y; - mvwprintw(editw, y, FIELDS_START_X, "%d - %s", - j, - gettext(abook_fields[i].name)); + mvwprintw(editw, y, FIELDS_START_X, "%c - ", + (j < 10) ? '0' + j : 'A' + j - 10); + mvwaddnstr(editw, y, FIELDS_START_X + 4, cur->field->name, + bytes2width(cur->field->name, + FIELDNAME_MAX_WIDTH)); mvwaddch(editw, y, TAB_COLON_POS, ':'); - mvwaddstr(editw, y, TAB_COLON_POS + 2, - safe_str(database[item][i])); + + if((cur->field->type == FIELD_EMAILS) || + (cur->field->type == FIELD_LIST)) { + abook_list *emails, *e; + + find_field_number(cur->field->key, &nb); + emails = csv_to_abook_list(db_fget_byid(item, nb)); + + for(e = emails; e; e = e->next) { + getyx(editw, y, x); + mvwaddnstr(editw, y + 1, TAB_COLON_POS + 2, + e->data, + bytes2width(e->data, + FIELD_MAX_WIDTH)); + mvwaddch(editw, y + 1, TAB_COLON_POS, + UI_VLINE_CHAR); + } + if(emails) { + mvwaddch(editw, y + 2, TAB_COLON_POS, + UI_LLCORNER_CHAR); + mvwhline(editw, y + 2, TAB_COLON_POS + 1, + UI_HLINE_CHAR, + EDITW_COLS - TAB_COLON_POS - 2); + } + abook_list_free(&emails); + } else if(cur->field->type == FIELD_DATE) { + int day, month, year; + char buf[12]; + + find_field_number(cur->field->key, &nb); + if((str = db_fget_byid(item, nb)) != NULL) + strncpy(buf, str, sizeof(buf)); + + if(str && parse_date_string(buf, &day, &month, &year)) { + if(year) + str = strdup_printf("%04d-%02d-%02d", + year, month, day); + else + str = strdup_printf("--%02d-%02d", + month, day); + mvwaddnstr(editw, y, TAB_COLON_POS + 2, str, + bytes2width(str, FIELD_MAX_WIDTH)); + free(str); + } + } else { + find_field_number(cur->field->key, &nb); + str = safe_str(db_fget_byid(item, nb)); + mvwaddnstr(editw, y, TAB_COLON_POS + 2, str, + bytes2width(str, FIELD_MAX_WIDTH)); + } j++; } @@ -258,22 +279,19 @@ editor_print_data(int tab, int item) * (char **field) * a pointer to a pointer which will point a new string. if the latter * pointer != NULL it will be freed (if user doesn't cancel) + * (size_t max_len) + * maximum length of field to read from user * * returns (int) * a nonzero value if user has cancelled and zero if user has typed a * valid string */ - static int -change_field(char *msg, char **field) +change_field(char *msg, char **field, size_t max_len) { - int max_len = MAX_FIELD_LEN; char *old; int ret = 0; - if(!strncmp("E-mail", msg, 6)) - max_len = MAX_EMAIL_LEN; - old = *field; *field = ui_readline(msg, old, max_len - 1, 0); @@ -293,13 +311,14 @@ change_field(char *msg, char **field) return ret; } -static void -change_name_field(char **field) +static int +change_name_field(char *msg, char **field, size_t max_len) { char *tmp; + int ret; tmp = xstrdup(*field); - change_field("Name: ", field); + ret = change_field(msg, field, max_len); if(*field == NULL || ! **field) { xfree(*field); @@ -307,6 +326,8 @@ change_name_field(char **field) } xfree(tmp); + + return ret; } static void @@ -317,83 +338,232 @@ fix_email_str(char *str) } static void -edit_emails(char c, int item) +edit_list(int item, int nb, int isemail) { - char *field; - char emails[MAX_EMAILS][MAX_EMAIL_LEN]; - char tmp[MAX_EMAILSTR_LEN] = ""; - int i, len; - int email_num = c - '2'; + char *field, *msg, *keys; + abook_list *list, *e; + int choice = 1, elem_count; + + list = csv_to_abook_list(db_fget_byid(item, nb)); + + for(e = list, elem_count = 0; e; e = e->next, elem_count++) + ; + + if(elem_count) { + keys = xstrndup(S_("keybindings_new_123456789|n123456789"), + elem_count + 1); + msg = strdup_printf(_("Choose %s to modify (<1>%s%c%s%s."), + isemail ? _("email") : _("item"), + (elem_count > 1) ? "-<" : "", + (elem_count > 1) ? '0' + elem_count : ')', + (elem_count > 1) ? ">)" : "", + (elem_count < MAX_LIST_ITEMS) ? + _(" or ew") : "" + ); + choice = statusline_askchoice( + msg, + keys, + (elem_count < MAX_LIST_ITEMS) ? 1 : 2 + ); + free(keys); + free(msg); + } - split_emailstr(item, emails); - field = xstrdup(emails[email_num]); + if(choice == 0) + return; + + field = (choice > 1) ? + xstrdup(abook_list_get(list, choice - 2)->data) : + NULL; - if(change_field("E-mail: ", &field)) + if(change_field(isemail ? _("E-mail: ") : _("Item: "), + &field, MAX_EMAIL_LEN)) return; /* user cancelled ( C-g ) */ - if(field) { - strncpy(emails[email_num], field, MAX_EMAIL_LEN); - fix_email_str(emails[email_num]); - } else - *emails[email_num] = 0; + /* TODO if list item contains commas, should use quotes instead */ + if(field) + fix_email_str(field); - xfree(database[item][EMAIL]); + if(choice == 1) + abook_list_append(&list, field); + else + abook_list_replace(&list, choice - 2, field); - for(i = 0; i < MAX_EMAILS; i++) { - if( *emails[i] ) { - strcat(tmp, emails[i]); - strcat(tmp, ","); - } - } + if(field) + xfree(field); - len = strlen(tmp); - if(tmp[len -1] == ',') - tmp[len-1] =0; + field = abook_list_to_csv(list); + db_fput_byid(item, nb, field ? field : xstrdup("")); + abook_list_free(&list); +} - database[item][EMAIL] = xstrdup(tmp); +static int is_valid_date(const int day, const int month, const int year) +{ + int valid = 1; + int month_length[13] = + { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + + /* + * leap year + */ + if ((!(year % 4)) && ((year % 100) || !(year % 400))) + month_length[2] = 29; + + if (month < 1 || month > 12) + valid = 0; + else if (day < 1 || day > month_length[month]) + valid = 0; + else if (year < 0) /* we don't accept negative year numbers */ + valid = 0; + + return valid; } -static int -edit_field(int tab, char c, int item) +int +parse_date_string(char *s, int *day, int *month, int *year) { - int i, j; - int n = c - '1' + 1; - char *str; + int i = 0; + char *p = s; + assert(s && day && month && year); + + if(*s == '-' && *s++ == '-') { /* omitted year */ + *year = 0; + p = ++s; + i++; + } - if(n < 1 || n > MAX_TAB_FIELDS) - return 0; + while(*s) { + if(isdigit(*s)) { + s++; + continue; + } else if(*s == '-') { + if(++i > 3) + return FALSE; + *s++ = '\0'; + switch(i) { + case 1: *year = safe_atoi(p); break; + case 2: *month = safe_atoi(p); break; + } + p = s; + } else + return FALSE; + } - edit_undo(item, BACKUP_ITEM); + if (i != 2 || !*p) + return FALSE; - if(tab == TAB_CONTACT) { - switch(c) { - case '1': change_name_field(&database[item][NAME]); - break; - case '2': - case '3': - case '4': - case '5': edit_emails(c, item); break; - default: return 0; - } - return 1; + *day = atoi(p); + + return is_valid_date(*day, *month, *year); +} + +static void +edit_date(int item, int nb) +{ + int i, date[3], old = FALSE; + char buf[12], *s = db_fget_byid(item, nb); + char *field[] = { N_("Day: "), N_("Month: "), N_("Year (optional): ") }; + + if(s) { + strncpy(buf, s, sizeof(buf)); + old = parse_date_string(buf, &date[0], &date[1], &date[2]); } - for(i = 0, j = 0; i< ITEM_FIELDS; i++) { - if(abook_fields[i].tab == tab) - j++; - if(j==n) - break; + for(i = 0; i < 3; i++) { + s = (old && date[i]) ? strdup_printf("%d", date[i]) : NULL; + if(change_field(gettext(field[i]), &s, 5)) + return; /* user aborted with ^G */ + + date[i] = (s && is_number(s)) ? atoi(s) : 0; + + if(!s) { + switch(i) { + case 0: db_fput_byid(item, nb, NULL); /*delete*/ + case 1: /* fall through */ return; + } + } else + xfree(s); } - if(j != n) - return 0; + /* ISO 8601 date, of the YYYY-MM-DD or --MM-DD format */ + if(is_valid_date(date[0], date[1], date[2])) { + if(date[2]) + s = strdup_printf("%04d-%02d-%02d", + date[2], date[1], date[0]); + else + s = strdup_printf("--%02d-%02d", date[1], date[0]); + + db_fput_byid(item, nb, xstrdup(s)); + } else + statusline_msg(_("Invalid date")); +} + +/* input range: 1-9A-Z + * output range: 0-34 */ +static int +key_to_field_number(char c) +{ + int n = c - '1'; + if(n >= 0 && n < 9) + return n; + + n = c - 'A' + 9; + if(n > 8 && n < 35) + return n; + + return -1; +} + +static void +edit_field(int tab, char c, int item_number) +{ + int i = 0, number, idx; + char *msg; + abook_field_list *f; + list_item item; + + if((number = key_to_field_number(c)) < 0) + return; + + edit_undo(item_number, BACKUP_ITEM); + + view_info(tab, NULL, &f); + + while(1) { + if(!f) + return; - str = strdup_printf("%s: ", gettext(abook_fields[i].name)); - change_field(str, &database[item][i]); + if(i == number) + break; - free(str); + f = f->next; + i++; + } - return 1; + find_field_number(f->field->key, &idx); + + switch(f->field->type) { + case FIELD_STRING: + msg = strdup_printf("%s: ", f->field->name); + item = db_item_get(item_number); + if(strcmp(f->field->key, "name") == 0) + change_name_field(msg,&item[idx],MAX_FIELD_LEN); + else + change_field(msg,&item[idx],MAX_FIELD_LEN); + free(msg); + break; + case FIELD_LIST: + edit_list(item_number, idx, 0); + break; + case FIELD_EMAILS: + edit_list(item_number, idx, 1); + break; + case FIELD_DATE: + edit_date(item_number, idx); + return; + default: + assert(0); + } } static int @@ -413,31 +583,44 @@ edit_loop(int item) refresh(); wrefresh(editw); - switch((c = getch())) { - case 'c': tab = TAB_CONTACT; break; - case 'a': tab = TAB_ADDRESS; break; - case 'p': tab = TAB_PHONE; break; - case 'o': tab = TAB_OTHER; break; - case 'C': tab = TAB_CUSTOM; break; + c = getch(); + if(c == '\033') { + statusline_addstr("ESC-"); + c = getch(); + clear_statusline(); + + /* Escaped bindings */ + switch(c) { + case 'r': roll_emails(item, ROTATE_RIGHT); break; + default: break; + } + + return item; + } + + /* No uppercase nor numeric key should be used in this menu, + * as they are reserved for field selection */ + switch(c) { case 'h': - case KEY_LEFT: tab = tab == 0 ? MAX_TAB : tab - 1; + case KEY_LEFT: tab = tab == 0 ? views_count - 1 : tab - 1; break; case 'l': - case KEY_RIGHT: tab = tab == MAX_TAB ? 0 : tab + 1; + case KEY_RIGHT: tab = tab == views_count - 1 ? 0 : tab + 1; break; case KEY_UP: case '<': - case 'k': if(is_valid_item(item-1)) item--; break; + case 'k': if(is_valid_item(item - 1)) item--; break; case KEY_DOWN: case '>': case 'j': if(is_valid_item(item + 1)) item++; break; - case 'r': roll_emails(item); break; + case 'r': roll_emails(item, ROTATE_LEFT); break; case '?': display_help(HELP_EDITOR); break; case 'u': item = edit_undo(item, RESTORE_ITEM); break; case 'm': launch_mutt(item); clearok(stdscr, 1); break; case 'v': launch_wwwbrowser(item); clearok(stdscr, 1); break; case 12 : clearok(stdscr, 1); break; /* ^L (refresh screen) */ - default: return edit_field(tab, c, item) ? item : -1; + case 'q': return -1; + default: edit_field(tab, c, item); } return item; @@ -446,17 +629,17 @@ edit_loop(int item) void edit_item(int item) { - if( item < 0 ) { - if( curitem < 0 ) + if(item < 0) { + if(list_get_curitem() < 0) return; else - item = curitem; + item = list_get_curitem(); } init_editor(); while((item = edit_loop(item)) >= 0) - curitem = item; /* hmm, this is not very clean way to go */ + list_set_curitem(item); /* this is not very clean way to go */ close_editor(); } @@ -465,21 +648,20 @@ void add_item() { char *field = NULL; - list_item item; + list_item item = item_create(); - change_field("Name: ", &field); + change_field(_("Name: "), &field, MAX_FIELD_LEN); if( field == NULL ) return; - memset(item, 0, sizeof(item)); - - item[NAME] = field; + item_fput(item, NAME, field); add_item2database(item); + item_free(&item); - curitem = LAST_ITEM; + list_set_curitem(last_item()); - edit_item(LAST_ITEM); + edit_item(last_item()); } diff --git a/edit.h b/edit.h index e9ac920..8f1ada5 100644 --- a/edit.h +++ b/edit.h @@ -4,32 +4,22 @@ void edit_item(int item); void get_first_email(char *str, int item); void add_item(); +int parse_date_string(char *s, int *day, int *month, int *year); #define EDITW_COLS (COLS - 6) #define EDITW_LINES (LINES - 5) #define EDITW_TOP 2 #define EDITW_X 3 -#define EDITOR_HELPLINE N_("?:help c:contact a:address p:phone o:other") +#define EDITOR_HELPLINE N_("?:help q:quit editor") #define TABLINE 1 -#define MAX_TAB_FIELDS 7 - #define TAB_COLON_POS 28 +#define FIELDNAME_MAX_WIDTH 20 +#define FIELD_MAX_WIDTH (EDITW_COLS - TAB_COLON_POS - FIELDS_START_X - 2) + #define FIELDS_START_Y 4 #define FIELDS_START_X 4 -enum { - TAB_CONTACT, - TAB_ADDRESS, - TAB_PHONE, - TAB_OTHER, - TAB_CUSTOM -}; - -#define MAX_TAB TAB_CUSTOM - -#define TABS (MAX_TAB+1) - #endif diff --git a/filter.c b/filter.c index 8d0faa9..f13d099 100644 --- a/filter.c +++ b/filter.c @@ -1,6 +1,6 @@ /* - * $Id: filter.c,v 1.48.2.1.2.2 2006/04/10 16:02:10 jheinonen Exp $ + * $Id: filter.c,v 1.55 2006/09/06 02:46:44 cduval Exp $ * * by JH * @@ -27,9 +27,8 @@ #include "xmalloc.h" #include -extern int items; -extern list_item *database; -extern struct abook_field abook_fields[]; +extern abook_field_list *fields_list; +extern int fields_count; /* * function declarations @@ -62,6 +61,7 @@ static int elm_alias_export(FILE *out, struct db_enumerator e); static int text_export_database(FILE *out, struct db_enumerator e); static int spruce_export_database(FILE *out, struct db_enumerator e); static int wl_export_database(FILE *out, struct db_enumerator e); +static int bsdcal_export_database(FILE *out, struct db_enumerator e); /* * end of function declarations @@ -92,6 +92,7 @@ struct abook_output_filter e_filters[] = { { "text", N_("plain text"), text_export_database }, { "wl", N_("Wanderlust address book"), wl_export_database }, { "spruce", N_("Spruce address book"), spruce_export_database }, + { "bsdcal", N_("BSD calendar"), bsdcal_export_database }, { "\0", NULL, NULL } }; @@ -194,7 +195,7 @@ import_database() { int filter; char *filename; - int tmp = items; + int tmp = db_n_items(); import_screen(); @@ -215,7 +216,7 @@ import_database() if(i_read_file(filename, i_filters[filter].func )) statusline_msg(_("Error occured while opening the file")); - else if(tmp == items) + else if(tmp == db_n_items()) statusline_msg(_("File does not seem to be a valid addressbook")); refresh_screen(); @@ -246,7 +247,7 @@ int import_file(char filtname[FILTNAME_LEN], char *filename) { int i; - int tmp = items; + int tmp = db_n_items(); int ret = 0; for(i=0;; i++) { @@ -271,7 +272,7 @@ import_file(char filtname[FILTNAME_LEN], char *filename) } else ret = i_read_file(filename, i_filters[i].func); - if(tmp == items) + if(tmp == db_n_items()) ret = 1; return ret; @@ -281,7 +282,7 @@ import_file(char filtname[FILTNAME_LEN], char *filename) * export */ -static int e_write_file(char *filename, +static int e_write_file(char *filename, int (*func) (FILE *in, struct db_enumerator e), int mode); static void @@ -531,10 +532,10 @@ ldif_read_line(FILE *in) static void ldif_add_item(ldif_item li) { - list_item abook_item; + list_item item; int i; - memset(abook_item, 0, sizeof(abook_item)); + item = item_create(); if(!li[LDIF_ITEM_FIELDS -1]) goto bail_out; @@ -542,14 +543,15 @@ ldif_add_item(ldif_item li) for(i=0; i < LDIF_ITEM_FIELDS; i++) { if(ldif_conv_table[i] >= 0 && li[i] && *li[i]) - abook_item[ldif_conv_table[i]] = xstrdup(li[i]); + item_fput(item,ldif_conv_table[i],xstrdup(li[i])); } - add_item2database(abook_item); + add_item2database(item); bail_out: for(i=0; i < LDIF_ITEM_FIELDS; i++) xfree(li[i]); + item_free(&item); } @@ -568,9 +570,11 @@ ldif_convert(ldif_item item, char *type, char *value) if(i == LDIF_ITEM_FIELDS - 1) /* this is a dirty hack */ if(safe_strcmp("person", value)) break; - if(item[i]) - xfree(item[i]); - item[i] = xstrdup(value); + + if(item_fget(item, i)) + free(item_fget(item, i)); + + item_fput(item, i, xstrdup(value)); } } } @@ -638,8 +642,7 @@ mutt_read_line(FILE *in, char **alias, char **rest) if( !(line = ptr = getaline(in)) ) return 1; /* error / EOF */ - while( ISSPACE(*ptr) ) - ptr++; + SKIPWS(ptr); if(strncmp("alias", ptr, 5)) { free(line); @@ -648,8 +651,7 @@ mutt_read_line(FILE *in, char **alias, char **rest) ptr += 5; - while( ISSPACE(*ptr) ) - ptr++; + SKIPWS(ptr); tmp = ptr; @@ -658,13 +660,13 @@ mutt_read_line(FILE *in, char **alias, char **rest) alias_len = (size_t)(ptr - tmp); - *alias = xmalloc_inc(alias_len, 1); + if(alias) + *alias = xmalloc_inc(alias_len, 1); strncpy(*alias, tmp, alias_len); *(*alias + alias_len) = 0; - while(ISSPACE(*ptr)) - ptr++; + SKIPWS(ptr); *rest = xstrdup(ptr); @@ -695,7 +697,7 @@ mutt_fix_quoting(char *p) static void mutt_parse_email(list_item item) { - char *line = item[NAME]; + char *line = item_fget(item, NAME); char *tmp; char *name, *email; #if 0 @@ -709,11 +711,12 @@ mutt_parse_email(list_item item) free(tmp); if(name) - item[NAME] = name; + item_fput(item, NAME, name); else return; + if(email) - item[EMAIL] = email; + item_fput(item, EMAIL, email); else return; @@ -742,22 +745,25 @@ mutt_parse_email(list_item item) static int mutt_parse_file(FILE *in) { - list_item item; + list_item item = item_create(); for(;;) { - memset(item, 0, sizeof(item)); + memset(item, 0, fields_count * sizeof(char *)); - if(!mutt_read_line(in, &item[NICK], - &item[NAME]) ) + if(!mutt_read_line(in, + (field_id(NICK) != -1) ? + &item[field_id(NICK)] : NULL, + &item[field_id(NAME)])) mutt_parse_email(item); if(feof(in)) { - free_list_item(item); + item_empty(item); break; } add_item2database(item); } + item_free(&item); return 0; } @@ -795,7 +801,8 @@ ldif_export_database(FILE *out, struct db_enumerator e) int j; get_first_email(email, e.item); - tmp = strdup_printf("cn=%s,mail=%s", database[e.item][NAME], email); + tmp = strdup_printf("cn=%s,mail=%s",db_name_get(e.item),email); + ldif_fput_type_and_value(out, "dn", tmp); free(tmp); @@ -804,10 +811,11 @@ ldif_export_database(FILE *out, struct db_enumerator e) if(ldif_conv_table[j] == EMAIL) ldif_fput_type_and_value(out, ldif_field_names[j], email); - else if(database[e.item][ldif_conv_table[j]]) + else if(db_fget(e.item,ldif_conv_table[j])) ldif_fput_type_and_value(out, ldif_field_names[j], - database[e.item][ldif_conv_table[j]]); + db_fget(e.item, + ldif_conv_table[j])); } } @@ -826,39 +834,56 @@ ldif_export_database(FILE *out, struct db_enumerator e) * html export filter */ -static void html_export_write_head(FILE *out, int extra); +static void html_export_write_head(FILE *out); static void html_export_write_tail(FILE *out); -extern int extra_column; +extern struct index_elem *index_elements; + +static void +html_print_emails(FILE *out, struct list_field *f) +{ + abook_list *l = csv_to_abook_list(f->data); + + for(; l; l = l->next) { + fprintf(out, "%s", l->data, l->data); + if(l->next) + fprintf(out, ", "); + } + + abook_list_free(&l); +} static int html_export_database(FILE *out, struct db_enumerator e) { - char tmp[MAX_EMAILSTR_LEN]; - int extra; + struct list_field f; + struct index_elem *cur; - if(items < 1) + if(list_is_empty()) return 2; - extra = (extra_column > 2 && extra_column < ITEM_FIELDS) ? - extra_column : PHONE; + init_index(); - html_export_write_head(out, extra); + html_export_write_head(out); db_enumerate_items(e) { - get_first_email(tmp, e.item); - if (*tmp) - fprintf(out, "\n%s\n", - tmp, - database[e.item][NAME] ); - else - fprintf(out, "\n%s\n", - database[e.item][NAME] ); - - fprintf(out, "%s\n%s\n", - database[e.item][EMAIL], - safe_str(database[e.item][extra]) ); - fprintf(out, "\n\n"); + fprintf(out, ""); + for(cur = index_elements; cur; cur = cur->next) { + if(cur->type != INDEX_FIELD) + continue; + + get_list_field(e.item, cur, &f); + + if(f.type == FIELD_EMAILS) { + fprintf(out, ""); + html_print_emails(out, &f); + fprintf(out, ""); + continue; + } else { + fprintf(out, "%s", safe_str(f.data)); + } + } + fprintf(out, "\n"); } html_export_write_tail(out); @@ -866,21 +891,28 @@ html_export_database(FILE *out, struct db_enumerator e) return 0; } - static void -html_export_write_head(FILE *out, int extra) +html_export_write_head(FILE *out) { - char *realname = get_real_name(); + char *realname = get_real_name(), *str; + struct index_elem *cur; fprintf(out, "\n"); - fprintf(out, "\n\n %s's addressbook", realname ); + fprintf(out, "\n\n %s's addressbook", + realname ); fprintf(out, "\n\n\n"); fprintf(out, "\n

%s's addressbook

\n", realname ); fprintf(out, "

\n\n"); - fprintf(out, "\n"); - fprintf(out, "\n\n\n", - abook_fields[extra].name); + fprintf(out, "
NameE-mail address(es)%s
\n"); + for(cur = index_elements; cur; cur = cur->next) { + if(cur->type != INDEX_FIELD) + continue; + + get_field_info(cur->d.field.id, NULL, &str, NULL); + fprintf(out, "", str); + } + fprintf(out, "\n\n"); free(realname); } @@ -928,10 +960,11 @@ pine_convert_emails(char *s) *tmp = '\0'; for(i = 1; ( tmp = strchr(s, ',') ) != NULL ; i++, s = tmp + 1) - if(i > MAX_EMAILS - 1) { + if(i > MAX_LIST_ITEMS - 1) { *tmp = '\0'; break; } + } static void @@ -942,11 +975,11 @@ pine_parse_buf(char *buf) char *end; char tmp[PINE_BUF_SIZE]; int i, len, last; - int pine_conv_table[] = {NICK, NAME, EMAIL, -1, NOTES}; + int pine_conv_table[]= {NICK, NAME, EMAIL, -1, NOTES}; - memset(&item, 0, sizeof(item)); + item = item_create(); - for(i = 0, last=0; !last ; i++) { + for(i=0, last=0; !last ; i++) { if( !(end = strchr(start, '\t')) ) last=1; @@ -958,13 +991,15 @@ pine_parse_buf(char *buf) strncpy(tmp, start, len); tmp[len] = 0; if(*tmp) - item[pine_conv_table[i]] = xstrdup(tmp); + item_fput(item, pine_conv_table[i], + xstrdup(tmp)); } start = end + 1; } - pine_convert_emails(item[EMAIL]); + pine_convert_emails(item_fget(item, EMAIL)); add_item2database(item); + item_free(&item); } @@ -1024,14 +1059,18 @@ pine_parse_file(FILE *in) static int pine_export_database(FILE *out, struct db_enumerator e) { + char *emails; + db_enumerate_items(e) { - fprintf(out, have_multiple_emails(e.item) ? + emails = db_email_get(e.item); + fprintf(out, strchr(emails, ',') /* multiple addresses? */ ? "%s\t%s\t(%s)\t\t%s\n" : "%s\t%s\t%s\t\t%s\n", - safe_str(database[e.item][NICK]), - safe_str(database[e.item][NAME]), - safe_str(database[e.item][EMAIL]), - safe_str(database[e.item][NOTES]) + safe_str(db_fget(e.item, NICK)), + safe_str(db_name_get(e.item)), + emails, + safe_str(db_fget(e.item, NOTES)) ); + free(emails); } return 0; @@ -1080,11 +1119,7 @@ static int allcsv_conv_table[] = { NICK, URL, NOTES, - CUSTOM1, - CUSTOM2, - CUSTOM3, - CUSTOM4, - CUSTOM5, + ANNIVERSARY }; static int palmcsv_conv_table[] = { @@ -1102,11 +1137,7 @@ static int palmcsv_conv_table[] = { STATE, ZIP, COUNTRY, - CUSTOM1, - CUSTOM2, - CUSTOM3, - CUSTOM4, - CUSTOM5, + ANNIVERSARY, }; static void @@ -1119,7 +1150,7 @@ csv_convert_emails(char *s) return; for(i = 1; ( tmp = strchr(s, ',') ) != NULL ; i++, s = tmp + 1) - if(i > MAX_EMAILS - 1) { + if(i > MAX_LIST_ITEMS - 1) { *tmp = 0; break; } @@ -1156,7 +1187,7 @@ static int csv_field_to_item(int *table_base, size_t table_size, int field) { if(field < table_size) - return table_base[field]; + return field_id(table_base[field]); return -1; } @@ -1225,7 +1256,7 @@ csv_parse_line(char *line, int *table_base, size_t table_size) bool in_quote = FALSE; list_item item; - memset(item, 0, sizeof(item)); + item = item_create(); for(p = start = line, field = 0; *p; p++) { if(in_quote) { @@ -1239,10 +1270,8 @@ csv_parse_line(char *line, int *table_base, size_t table_size) if(*p == ',' && !in_quote) { *p = 0; - csv_field_to_item(table_base, table_size, field); csv_store_item(item, - csv_field_to_item(table_base, - table_size, field), + csv_field_to_item(table_base,table_size,field), start); field++; start = p + 1; @@ -1254,8 +1283,9 @@ csv_parse_line(char *line, int *table_base, size_t table_size) csv_store_item(item, csv_field_to_item(table_base, table_size, field), start); - csv_convert_emails(item[EMAIL]); + csv_convert_emails(item_fget(item, EMAIL)); add_item2database(item); + item_free(&item); } static int @@ -1324,13 +1354,13 @@ csv_export_common(FILE *out, struct db_enumerator e, (*special_func)(out, e.item, fields[i]); } else /*fprintf(out,( - strchr(safe_str(database[e.item][fields[i]]), ',') || - strchr(safe_str(database[e.item][fields[i]]), '\"')) ? + strchr(safe_str(database[e.item][field_idx(fields[i])]), ',') || + strchr(safe_str(database[e.item][field_idx(fields[i])]), '\"')) ? "\"%s\"" : "%s", - safe_str(database[e.item][fields[i]]) + safe_str(database[e.item][field_idx(fields[i])]) );*/ fprintf(out, "\"%s\"", - safe_str(database[e.item][fields[i]])); + safe_str(db_fget(e.item,fields[i]))); if(fields[i + 1] != CSV_LAST) fputc(',', out); @@ -1381,11 +1411,7 @@ allcsv_export_database(FILE *out, struct db_enumerator e) NICK, URL, NOTES, - CUSTOM1, - CUSTOM2, - CUSTOM3, - CUSTOM4, - CUSTOM5, + ANNIVERSARY, CSV_LAST }; @@ -1405,11 +1431,7 @@ allcsv_export_database(FILE *out, struct db_enumerator e) fprintf(out, "\"NICK\","); fprintf(out, "\"URL\","); fprintf(out, "\"NOTES\","); - fprintf(out, "\"CUSTOM1\","); - fprintf(out, "\"CUSTOM2\","); - fprintf(out, "\"CUSTOM3\","); - fprintf(out, "\"CUSTOM4\","); - fprintf(out, "\"CUSTOM5\"\n"); + fprintf(out, "\"ANNIVERSARY\"\n"); csv_export_common(out, e, allcsv_export_fields, NULL); @@ -1448,7 +1470,7 @@ palm_csv_handle_specials(FILE *out, int item, int field) { switch(field) { case PALM_CSV_NAME: - palm_split_and_write_name(out, database[item][NAME]); + palm_split_and_write_name(out, db_name_get(item)); break; case PALM_CSV_CAT: fprintf(out, "\"abook\""); @@ -1504,62 +1526,67 @@ palm_export_database(FILE *out, struct db_enumerator e) static int gcrd_export_database(FILE *out, struct db_enumerator e) { - char emails[MAX_EMAILS][MAX_EMAIL_LEN]; int j; - char *name; + char *name, *tmp; + abook_list *emails, *em; db_enumerate_items(e) { fprintf(out, "BEGIN:VCARD\r\nFN:%s\r\n", - safe_str(database[e.item][NAME])); + safe_str(db_name_get(e.item))); - name = get_surname(database[e.item][NAME]); - for( j = strlen(database[e.item][NAME]) - 1; j >= 0; j-- ) { - if(database[e.item][NAME][j] == ' ') + name = get_surname(db_name_get(e.item)); + for( j = strlen(db_name_get(e.item)) - 1; j >= 0; j-- ) { + if((db_name_get(e.item))[j] == ' ') break; } fprintf(out, "N:%s;%.*s\r\n", safe_str(name), j, - safe_str(database[e.item][NAME]) + safe_str(db_name_get(e.item)) ); free(name); - if ( database[e.item][ADDRESS] ) + if(db_fget(e.item, ADDRESS)) fprintf(out, "ADR:;;%s;%s;%s;%s;%s;%s\r\n", - safe_str(database[e.item][ADDRESS]), - safe_str(database[e.item][ADDRESS2]), - safe_str(database[e.item][CITY]), - safe_str(database[e.item][STATE]), - safe_str(database[e.item][ZIP]), - safe_str(database[e.item][COUNTRY]) + safe_str(db_fget(e.item, ADDRESS)), + safe_str(db_fget(e.item, ADDRESS2)), + safe_str(db_fget(e.item, CITY)), + safe_str(db_fget(e.item, STATE)), + safe_str(db_fget(e.item, ZIP)), + safe_str(db_fget(e.item, COUNTRY)) ); - if (database[e.item][PHONE]) + if(db_fget(e.item, PHONE)) fprintf(out, "TEL;HOME:%s\r\n", - database[e.item][PHONE]); - if (database[e.item][WORKPHONE]) + db_fget(e.item, PHONE)); + if(db_fget(e.item, WORKPHONE)) fprintf(out, "TEL;WORK:%s\r\n", - database[e.item][WORKPHONE]); - - if (database[e.item][FAX]) - fprintf(out, "TEL;FAX:%s\r\n", database[e.item][FAX]); - if (database[e.item][MOBILEPHONE]) - fprintf(out, "TEL;CELL:%s\r\n", database[e.item][MOBILEPHONE]); - - if ( database[e.item][EMAIL] ) { - split_emailstr(e.item, emails); - for(j=0; j < MAX_EMAILS ; j++) { - if ( *emails[j] ) - fprintf(out, "EMAIL;INTERNET:%s\r\n", - emails[j]); - } + db_fget(e.item, WORKPHONE)); + if(db_fget(e.item, FAX)) + fprintf(out, "TEL;FAX:%s\r\n", + db_fget(e.item, FAX)); + if(db_fget(e.item, MOBILEPHONE)) + fprintf(out, "TEL;CELL:%s\r\n", + db_fget(e.item, MOBILEPHONE)); + + tmp = db_email_get(e.item); + if(*tmp) { + emails = csv_to_abook_list(tmp); + + for(em = emails; em; em = em->next) + fprintf(out, "EMAIL;INTERNET:%s\r\n", em->data); + + abook_list_free(&emails); } + free(tmp); - if ( database[e.item][NOTES] ) - fprintf(out, "NOTE:%s\r\n", database[e.item][NOTES]); - if (database[e.item][URL]) - fprintf(out, "URL:%s\r\n", database[e.item][URL]); + if(db_fget(e.item, NOTES)) + fprintf(out, "NOTE:%s\r\n", + db_fget(e.item, NOTES)); + if(db_fget(e.item, URL)) + fprintf(out, "URL:%s\r\n", + db_fget(e.item, URL)); fprintf(out, "END:VCARD\r\n\r\n"); @@ -1582,10 +1609,10 @@ mutt_alias_genalias(int i) { char *tmp, *pos; - if(database[i][NICK]) - return xstrdup(database[i][NICK]); + if(db_fget(i, NICK)) + return xstrdup(db_fget(i, NICK)); - tmp = xstrdup(database[i][NAME]); + tmp = xstrdup(db_name_get(i)); if( ( pos = strchr(tmp, ' ') ) ) *pos = 0; @@ -1603,11 +1630,10 @@ mutt_alias_export(FILE *out, struct db_enumerator e) db_enumerate_items(e) { alias = mutt_alias_genalias(e.item); - get_first_email(email, e.item); fprintf(out, *email ? "alias %s %s <%s>\n": "alias %s %s%s\n", alias, - database[e.item][NAME], + db_name_get(e.item), email); xfree(alias); } @@ -1627,29 +1653,29 @@ mutt_alias_export(FILE *out, struct db_enumerator e) static void text_write_address_us(FILE *out, int i) { - fprintf(out, "\n%s", database[i][ADDRESS]); + fprintf(out, "\n%s", db_fget(i, ADDRESS)); - if (database[i][ADDRESS2]) - fprintf(out, "\n%s", database[i][ADDRESS2]); + if(db_fget(i, ADDRESS2)) + fprintf(out, "\n%s", db_fget(i, ADDRESS2)); - if (database[i][CITY]) - fprintf(out, "\n%s", database[i][CITY]); + if(db_fget(i, CITY)) + fprintf(out, "\n%s", db_fget(i, CITY)); - if (database[i][STATE] || database[i][ZIP]) { + if(db_fget(i, STATE) || db_fget(i, ZIP)) { fputc('\n', out); - if(database[i][STATE]) { - fprintf(out, "%s", database[i][STATE]); - if(database[i][ZIP]) + if(db_fget(i, STATE)) { + fprintf(out, "%s", db_fget(i, STATE)); + if(db_fget(i, ZIP)) fputc(' ', out); } - if(database[i][ZIP]) - fprintf(out, "%s", database[i][ZIP]); + if(db_fget(i, ZIP)) + fprintf(out, "%s", db_fget(i, ZIP)); } - if (database[i][COUNTRY]) - fprintf(out, "\n%s", database[i][COUNTRY]); + if(db_fget(i, COUNTRY)) + fprintf(out, "\n%s", db_fget(i, COUNTRY)); } @@ -1657,44 +1683,43 @@ static void text_write_address_uk(FILE *out, int i) { int j; - for (j = ADDRESS; j <= COUNTRY; j++) - if (database[i][j]) - fprintf(out, "\n%s", database[i][j]); + for(j = ADDRESS; j <= COUNTRY; j++) + if(db_fget(i, j)) + fprintf(out, "\n%s", db_fget(i, j)); } static void text_write_address_eu(FILE *out, int i) { - fprintf(out, "\n%s", database[i][ADDRESS]); + fprintf(out, "\n%s", db_fget(i, ADDRESS)); - if (database[i][ADDRESS2]) - fprintf(out, "\n%s", database[i][ADDRESS2]); + if(db_fget(i, ADDRESS2)) + fprintf(out, "\n%s", db_fget(i, ADDRESS2)); - if (database[i][ZIP] || database[i][CITY]) { + if(db_fget(i, ZIP) || db_fget(i, CITY)) { fputc('\n', out); - if(database[i][ZIP]) { - fprintf(out, "%s", database[i][ZIP]); - if(database[i][CITY]) + if(db_fget(i, ZIP)) { + fprintf(out, "%s", db_fget(i, ZIP)); + if(db_fget(i, CITY)) fputc(' ', out); } - if(database[i][CITY]) - fprintf(out, "%s", database[i][CITY]); + fprintf(out, "%s", safe_str(db_fget(i, CITY))); } - if (database[i][STATE]) - fprintf(out, "\n%s", database[i][STATE]); + if(db_fget(i, STATE)) + fprintf(out, "\n%s", db_fget(i, STATE)); - if (database[i][COUNTRY]) - fprintf(out, "\n%s", database[i][COUNTRY]); + if(db_fget(i, COUNTRY)) + fprintf(out, "\n%s", db_fget(i, COUNTRY)); } static int text_export_database(FILE * out, struct db_enumerator e) { - char emails[MAX_EMAILS][MAX_EMAIL_LEN]; + abook_list *emails, *em; int j; - char *realname = get_real_name(); + char *realname = get_real_name(), *str = NULL, *tmp; char *style = opt_get_str(STR_ADDRESS_STYLE); fprintf(out, @@ -1706,23 +1731,27 @@ text_export_database(FILE * out, struct db_enumerator e) db_enumerate_items(e) { fprintf(out, "-----------------------------------------\n\n"); - fprintf(out, "%s", database[e.item][NAME]); - if (database[e.item][NICK] && *database[e.item][NICK]) - fprintf(out, "\n(%s)", database[e.item][NICK]); + fprintf(out, "%s", db_name_get(e.item)); + if(db_fget(e.item, NICK) && *db_fget(e.item, NICK)) + fprintf(out, "\n(%s)", db_fget(e.item, NICK)); fprintf(out, "\n"); - if (*database[e.item][EMAIL]) { + tmp = db_email_get(e.item); + if(*tmp) { + emails = csv_to_abook_list(tmp); + fprintf(out, "\n"); - split_emailstr(e.item, emails); - for (j = 0; j < MAX_EMAILS; j++) - if (*emails[j]) - fprintf(out, "%s\n", emails[j]); + for(em = emails; em; em = em->next) + fprintf(out, "%s\n", em->data); + + abook_list_free(&emails); } + free(tmp); /* Print address */ - if (database[e.item][ADDRESS]) { - if (!safe_strcmp(style, "us")) /* US like */ + if(db_fget(e.item, ADDRESS)) { + if(!safe_strcmp(style, "us")) /* US like */ text_write_address_us(out, e.item); - else if (!safe_strcmp(style, "uk")) /* UK like */ + else if(!safe_strcmp(style, "uk")) /* UK like */ text_write_address_uk(out, e.item); else /* EU like */ text_write_address_eu(out, e.item); @@ -1730,22 +1759,24 @@ text_export_database(FILE * out, struct db_enumerator e) fprintf(out, "\n"); } - if ((database[e.item][PHONE]) || - (database[e.item][WORKPHONE]) || - (database[e.item][FAX]) || - (database[e.item][MOBILEPHONE])) { + if((db_fget(e.item, PHONE)) || + (db_fget(e.item, WORKPHONE)) || + (db_fget(e.item, FAX)) || + (db_fget(e.item, MOBILEPHONE))) { fprintf(out, "\n"); - for (j = PHONE; j <= MOBILEPHONE; j++) - if (database[e.item][j]) - fprintf(out, "%s: %s\n", - abook_fields[j].name, - database[e.item][j]); + for(j = PHONE; j <= MOBILEPHONE; j++) + if(db_fget(e.item, j)) { + get_field_info(field_id(j), + NULL, &str, NULL); + fprintf(out, "%s: %s\n", str, + db_fget(e.item, j)); + } } - if (database[e.item][URL]) - fprintf(out, "\n%s\n", database[e.item][URL]); - if (database[e.item][NOTES]) - fprintf(out, "\n%s\n", database[e.item][NOTES]); + if(db_fget(e.item, URL)) + fprintf(out, "\n%s\n", db_fget(e.item, URL)); + if(db_fget(e.item, NOTES)) + fprintf(out, "\n%s\n", db_fget(e.item, NOTES)); fprintf(out, "\n"); } @@ -1772,10 +1803,7 @@ elm_alias_export(FILE *out, struct db_enumerator e) db_enumerate_items(e) { alias = mutt_alias_genalias(e.item); get_first_email(email, e.item); - fprintf(out, "%s = %s = %s\n", - alias, - database[e.item][NAME], - email); + fprintf(out, "%s = %s = %s\n",alias,db_name_get(e.item),email); xfree(alias); } @@ -1796,16 +1824,16 @@ spruce_export_database (FILE *out, struct db_enumerator e) { char email[MAX_EMAIL_LEN]; - fprintf (out, "# This is a generated file made by abook for the Spruce e-mail client.\n\n"); + fprintf(out, "# This is a generated file made by abook for the Spruce e-mail client.\n\n"); db_enumerate_items(e) { - if(strcmp (safe_str(database[e.item][EMAIL]), "")) { - get_first_email(email, e.item); + get_first_email(email, e.item); + if(strcmp(email, "")) { fprintf(out, "# Address %d\nName: %s\nEmail: %s\nMemo: %s\n\n", e.item, - database[e.item][NAME], + db_name_get(e.item), email, - safe_str(database[e.item][NOTES]) + safe_str(db_fget(e.item, NOTES)) ); } } @@ -1826,17 +1854,17 @@ spruce_export_database (FILE *out, struct db_enumerator e) static int wl_export_database(FILE *out, struct db_enumerator e) { - char emails[MAX_EMAILS][MAX_EMAIL_LEN]; + char email[MAX_EMAIL_LEN]; - fprintf (out, "# Wanderlust address book written by %s\n\n", PACKAGE); + fprintf(out, "# Wanderlust address book written by %s\n\n", PACKAGE); db_enumerate_items(e) { - split_emailstr(e.item, emails); - if (**emails) { + get_first_email(email, e.item); + if(*email) { fprintf(out, "%s\t\"%s\"\t\"%s\"\n", - *emails, - safe_str(database[e.item][NICK]), - safe_str(database[e.item][NAME]) + email, + safe_str(db_fget(e.item, NICK)), + safe_str(db_name_get(e.item)) ); } } @@ -1850,3 +1878,33 @@ wl_export_database(FILE *out, struct db_enumerator e) * end of wanderlust addressbook export filter */ +/* + * BSD calendar export filter + */ + +static int +bsdcal_export_database(FILE *out, struct db_enumerator e) +{ + db_enumerate_items(e) { + int year, month = 0, day = 0; + char *anniversary = db_fget(e.item, ANNIVERSARY); + + if(anniversary) { + parse_date_string(anniversary, &day, &month, &year); + + fprintf(out, + _("%02d/%02d\tAnniversary of %s\n"), + month, + day, + safe_str(db_name_get(e.item)) + ); + } + } + + return 0; +} + +/* + * end of BSD calendar export filter + */ + diff --git a/help.h b/help.h index 776a000..cda0ec5 100644 --- a/help.h +++ b/help.h @@ -52,14 +52,17 @@ NULL static char *editorhelp[] = { "\n", -N_(" a,c,p,o,C/arrows/h,l change tab\n"), +N_(" arrows/h,l change tab\n"), "\n", -N_(" 1 - 5 edit fields\n"), +N_(" q quit to main screen\n"), +"\n", +N_(" 1 - 5 A - Z edit fields\n"), "\n", N_(" k or < previous item\n"), N_(" j or > next item\n"), "\n", -N_(" r roll e-mail addresses\n"), +N_(" r roll e-mail addresses up\n"), +N_(" ESC-r roll e-mail addresses down\n"), "\n", N_(" u undo\n"), "\n", diff --git a/intl/Makefile.in b/intl/Makefile.in index 25499c0..b7a866f 100644 --- a/intl/Makefile.in +++ b/intl/Makefile.in @@ -32,6 +32,7 @@ transform = @program_transform_name@ libdir = @libdir@ includedir = @includedir@ datadir = @datadir@ +datarootdir = @datarootdir@ localedir = $(datadir)/locale gettextsrcdir = $(datadir)/gettext/intl aliaspath = $(localedir) diff --git a/list.c b/list.c index 1c25085..a6d442f 100644 --- a/list.c +++ b/list.c @@ -1,6 +1,6 @@ /* - * $Id: list.c,v 1.27 2005/09/17 10:10:26 jheinonen Exp $ + * $Id: list.c,v 1.33 2006/09/05 08:21:35 jheinonen Exp $ * * by JH * @@ -20,43 +20,108 @@ #include "options.h" #include "xmalloc.h" -#define MIN_EXTRA_COLUMN ADDRESS /* 2 */ -#define MAX_EXTRA_COLUMN LAST_FIELD int curitem = -1; int first_list_item = -1; char *selected = NULL; -int extra_column = -1; -int extra_alternative = -1; - -extern int items; -extern list_item *database; -extern struct abook_field abook_fields[]; +extern abook_field_list *fields_list; +struct index_elem *index_elements = NULL; static WINDOW *list = NULL; -static int -init_extra_field(enum str_opts option) + +static void +index_elem_add(int type, char *a, char *b) { - int i, ret = -1; - char *option_str; + struct index_elem *tmp = NULL, *cur, *cur2; + int field, len = 0; - option_str = opt_get_str(option); + if(!a || !*a) + return; - if(option_str && *option_str) { - for(i = 0; i < ITEM_FIELDS; i++) { - if(!strcasecmp(option_str, abook_fields[i].key)) { - ret = i; - break; - } - } - if(ret < MIN_EXTRA_COLUMN || ret > MAX_EXTRA_COLUMN) { - ret = -1; - } + switch(type) { + case INDEX_TEXT: + tmp = xmalloc(sizeof(struct index_elem)); + tmp->d.text = xstrdup(a); + break; + case INDEX_FIELD: /* fall through */ + case INDEX_ALT_FIELD: + find_field_number(a, &field); + if(field == -1) + return; + len = (b && *b && is_number(b)) ? atoi(b) : 0; + tmp = xmalloc(sizeof(struct index_elem)); + tmp->d.field.id = field; + tmp->d.field.len = len; + break; + default: + assert(0); + } + tmp->type = type; + tmp->next = NULL; + tmp->d.field.next = NULL; + + if(!index_elements) { /* first element */ + index_elements = tmp; + return; + } + + for(cur = index_elements; cur->next; cur = cur->next) + ; + if(type != INDEX_ALT_FIELD) + cur->next = tmp; + else { /* add as an alternate field */ + tmp->d.field.len = cur->d.field.len; + for(cur2 = cur; cur2->d.field.next; cur2 = cur2->d.field.next) + ; + cur2->d.field.next = tmp; + } +} + +static void +parse_index_format(char *s) +{ + char *p, *start, *lstart = NULL; + int in_field = 0, in_alternate = 0, in_length = 0, type; + + p = start = s; + + while(*p) { + if(*p == '{' && !in_field) { + *p = 0; + index_elem_add(INDEX_TEXT, start, NULL); + start = ++p; + in_field = 1; + } else if(*p == ':' && in_field && !in_alternate) { + *p = 0; + lstart = ++p; + in_length = 1; + } else if(*p == '|' && in_field) { + *p = 0; + type = in_alternate ? INDEX_ALT_FIELD : INDEX_FIELD; + index_elem_add(type, start, in_length ? lstart : NULL); + start = ++p; + in_length = 0; + in_alternate = 1; + } else if(*p == '}' && in_field) { + *p = 0; + type = in_alternate ? INDEX_ALT_FIELD : INDEX_FIELD; + index_elem_add(type, start, in_length ? lstart : NULL); + start = ++p; + in_field = in_alternate = in_length = 0; + } else + p++; } + if(!in_field) + index_elem_add(INDEX_TEXT, start, NULL); +} - return ret; +void +init_index() +{ + assert(!index_elements); + parse_index_format(opt_get_str(STR_INDEX_FORMAT)); } void @@ -64,13 +129,6 @@ init_list() { list = newwin(LIST_LINES, LIST_COLS, LIST_TOP, 0); scrollok(list, TRUE); - - /* - * init extra_column and extra alternative - */ - - extra_column = init_extra_field(STR_EXTRA_COLUMN); - extra_alternative = init_extra_field(STR_EXTRA_ALTERNATIVE); } void @@ -80,6 +138,117 @@ close_list() list = NULL; } +void +get_list_field(int item, struct index_elem *e, struct list_field *res) +{ + char *s; + + res->data = s = NULL; + + do { /* find first non-empty field data in the alternate fields list */ + s = db_fget_byid(item, e->d.field.id); + } while(!(s && *s) && ((e = e->d.field.next) != NULL)); + + if(!e || !s || !*s) + return; + + res->data = s; + get_field_info(e->d.field.id, NULL, NULL, &res->type); +} + +static void +print_list_field(int item, int line, int *x_pos, struct index_elem *e) +{ + char *s, *p; + int width, x_start, mustfree = FALSE, len = abs(e->d.field.len); + struct list_field f; + + get_list_field(item, e, &f); + s = f.data; + + if(!s || !*s) { + *x_pos += len; + return; + } + + if(f.type == FIELD_EMAILS && !opt_get_bool(BOOL_SHOW_ALL_EMAILS)) + if((p = strchr(s, ',')) != NULL) { + s = xstrndup(s, p - s); + mustfree = TRUE; + } + + width = len ? bytes2width(s, len) : strwidth(s); + x_start = *x_pos + ((e->d.field.len < 0) ? len - width : 0); + if(width + x_start >= COLS) + width = COLS - x_start; + + if(width) + mvwaddnstr(list, line, x_start, s, width); + + if(mustfree) + free(s); + + *x_pos += len ? len : width; +} + +static void +highlight_line(WINDOW *win, int line) +{ + wstandout(win); + + /* + * this is a tricky one + */ +#if 0 +/*#ifdef mvwchgat*/ + mvwchgat(win, line, 0, -1, A_STANDOUT, 0, NULL); +#else + /* + * buggy function: FIXME + */ + scrollok(win, FALSE); + { + int i; + wmove(win, line, 0); + for(i = 0; i < COLS; i++) + waddch(win, ' '); + /*wattrset(win, 0);*/ + } + scrollok(win, TRUE); +#endif +} + +static void +print_list_line(int item, int line, int highlight) +{ + struct index_elem *cur; + int x_pos = 1; + + scrollok(list, FALSE); + if(highlight) + highlight_line(list, line); + + if(selected[item]) + mvwaddch(list, line, 0, '*' ); + + for(cur = index_elements; cur; cur = cur->next) + switch(cur->type) { + case INDEX_TEXT: + mvwaddstr(list, line, x_pos, cur->d.text); + x_pos += strwidth(cur->d.text); + break; + case INDEX_FIELD: + print_list_field(item, line, &x_pos, cur); + break; + default: + assert(0); + } + + scrollok(list, TRUE); + if(highlight) + wstandend(list); +} + void refresh_list() { @@ -106,8 +275,9 @@ refresh_list() else if(curitem > LAST_LIST_ITEM) first_list_item = max(curitem - LIST_LINES + 1, 0); - for( line = 0, i = first_list_item ; i <= LAST_LIST_ITEM && i < items; - line++, i++ ) { + for(line = 0, i = first_list_item; + i <= LAST_LIST_ITEM && i < db_n_items(); + line++, i++) { print_list_line(i, line, i == curitem); } @@ -120,56 +290,28 @@ refresh_list() wrefresh(list); } -void -print_list_line(int i, int line, int highlight) -{ - int extra = extra_column; - char tmp[MAX_EMAILSTR_LEN]; - int real_emaillen = (extra_column > 0 || extra_alternative > 0) ? - EMAILLEN : COLS - EMAILPOS; - - scrollok(list, FALSE); - if(highlight) - highlight_line(list, line); - - if(selected[i]) - mvwaddch(list, line, 0, '*' ); - - mvwaddnstr(list, line, NAMEPOS, database[i][NAME], - bytes2width(database[i][NAME], NAMELEN)); - if(opt_get_bool(BOOL_SHOW_ALL_EMAILS)) - mvwaddnstr(list, line, EMAILPOS, database[i][EMAIL], - bytes2width(database[i][EMAIL], real_emaillen)); - else { - get_first_email(tmp, i); - mvwaddnstr(list, line, EMAILPOS, tmp, - bytes2width(tmp, real_emaillen)); - } - - if(extra < 0 || !database[i][extra]) - extra = extra_alternative; - if(extra >= 0) - mvwaddnstr(list, line, EXTRAPOS, - safe_str(database[i][extra]), - bytes2width(safe_str(database[i][extra]), EXTRALEN)); - - scrollok(list, TRUE); - if(highlight) - wstandend(list); -} - - void list_headerline() { + struct index_elem *e; + int x_pos = 1, width; + char *str = NULL; + #if defined(A_BOLD) && defined(A_NORMAL) attrset(A_BOLD); #endif - mvaddstr(2, NAMEPOS, gettext(abook_fields[NAME].name)); - mvaddstr(2, EMAILPOS, gettext(abook_fields[EMAIL].name)); - if(extra_column > 0) - mvaddnstr(2, EXTRAPOS, gettext(abook_fields[extra_column].name), - COLS-EXTRAPOS); + + for(e = index_elements; e; e = e->next) + if(e->type == INDEX_TEXT) + x_pos += strwidth(e->d.text); + else if(e->type == INDEX_FIELD) { + get_field_info(e->d.field.id, NULL, &str, NULL); + width = e->d.field.len ? abs(e->d.field.len) : strwidth(str); + mvaddnstr(2, x_pos, str, width); + x_pos += width; + } else + assert(0); + #if defined(A_BOLD) && defined(A_NORMAL) attrset(A_NORMAL); #endif @@ -189,7 +331,7 @@ scroll_up() void scroll_down() { - if(curitem > items - 2) + if(curitem > db_n_items() - 2) return; curitem++; @@ -213,12 +355,15 @@ page_up() void page_down() { - if(curitem > items - 2) + if(curitem > db_n_items() - 2) return; - curitem = curitem == LAST_LIST_ITEM ? - ((curitem += LIST_LINES) > LAST_ITEM ? LAST_ITEM : curitem) : - min(LAST_LIST_ITEM, LAST_ITEM); + if(curitem == LAST_LIST_ITEM) { + if((curitem += LIST_LINES) > last_item()) + curitem = last_item(); + } else { + curitem = min(LAST_LIST_ITEM, last_item()); + } refresh_list(); } @@ -226,13 +371,29 @@ page_down() void select_none() { - memset(selected, 0, items); + memset(selected, 0, db_n_items()); } void select_all() { - memset(selected, 1, items); + memset(selected, 1, db_n_items()); +} + +void +list_set_selection(int item, int value) +{ + assert(is_valid_item(item)); + + selected[item] = !!value; +} + +void +list_invert_curitem_selection() +{ + assert(is_valid_item(curitem)); + + selected[curitem] = !selected[curitem]; } void @@ -240,34 +401,40 @@ move_curitem(int direction) { list_item tmp; - if( curitem < 0 || curitem > LAST_ITEM ) + if(curitem < 0 || curitem > last_item()) return; - itemcpy(tmp, database[curitem]); - - switch(direction) { - case MOVE_ITEM_UP: - if( curitem < 1 ) - return; - itemcpy(database[curitem], database[curitem - 1]); - itemcpy(database[curitem-1], tmp); - scroll_up(); - break; - - case MOVE_ITEM_DOWN: - if( curitem >= LAST_ITEM ) - return; - itemcpy(database[curitem], database[curitem + 1]); - itemcpy(database[curitem+1], tmp); - scroll_down(); - break; - } + tmp = item_create(); + item_copy(tmp, db_item_get(curitem)); + + switch(direction) { + case MOVE_ITEM_UP: + if( curitem < 1 ) + goto out_move; + item_copy(db_item_get(curitem), + db_item_get(curitem - 1)); + item_copy(db_item_get(curitem-1), tmp); + scroll_up(); + break; + + case MOVE_ITEM_DOWN: + if(curitem >= last_item()) + goto out_move; + item_copy(db_item_get(curitem), + db_item_get(curitem + 1)); + item_copy(db_item_get(curitem + 1), tmp); + scroll_down(); + break; + } + +out_move: + item_free(&tmp); } void goto_home() { - if(items > 0) + if(db_n_items() > 0) curitem = 0; refresh_list(); @@ -276,46 +443,18 @@ goto_home() void goto_end() { - if(items > 0) - curitem = LAST_ITEM; + if(db_n_items() > 0) + curitem = last_item(); refresh_list(); } - -void -highlight_line(WINDOW *win, int line) -{ - wstandout(win); - - /* - * this is a tricky one - */ -#if 0 -/*#ifdef mvwchgat*/ - mvwchgat(win, line, 0, -1, A_STANDOUT, 0, NULL); -#else - /* - * buggy function: FIXME - */ - scrollok(win, FALSE); - { - int i; - wmove(win, line, 0); - for(i = 0; i < COLS; i++) - waddch(win, ' '); - /*wattrset(win, 0);*/ - } - scrollok(win, TRUE); -#endif -} - int selected_items() { int i, n = 0; - for(i = 0; i < items; i++) + for(i = 0; i < db_n_items(); i++) if(selected[i]) n++; @@ -327,42 +466,48 @@ invert_selection() { int i; - if(items < 1) + if(list_is_empty()) return; - for(i = 0; i < items; i++) + for(i = 0; i < db_n_items(); i++) selected[i] = !selected[i]; } int -list_current_item() +list_is_empty() { - return curitem; + return db_n_items() < 1; } int -list_is_empty() +list_get_curitem() +{ + return curitem; +} + +void +list_set_curitem(int i) { - return items < 1; + curitem = i; } int duplicate_item() { - int i; list_item item; - + if(curitem < 0) return 1; - for(i = 0; i < ITEM_FIELDS; i++) - item[i] = database[curitem][i] ? xstrdup(database[curitem][i]) : - NULL; - - if(add_item2database(item)) + item = item_create(); + item_duplicate(item, db_item_get(curitem)); + if(add_item2database(item)) { + item_free(&item); return 1; + } + item_free(&item); - curitem = LAST_ITEM; + curitem = last_item(); refresh_list(); return 0; diff --git a/list.h b/list.h index ac8377f..45b00f8 100644 --- a/list.h +++ b/list.h @@ -3,10 +3,34 @@ #include "ui.h" +#define INDEX_TEXT 1 +#define INDEX_FIELD 2 +#define INDEX_ALT_FIELD 3 + +struct index_elem { + int type; + union { + char *text; + struct { + int id; + int len; + struct index_elem *next; + } field; + } d; + struct index_elem *next; +}; + +struct list_field { + char *data; + int type; +}; + +void init_index(); void init_list(); +int init_extra_field(enum str_opts option); void close_list(); void refresh_list(); -void print_list_line(int i, int line, int highlight); +void get_list_field(int item, struct index_elem *e, struct list_field *res); void list_headerline(); void scroll_up(); void scroll_down(); @@ -14,14 +38,16 @@ void page_up(); void page_down(); void select_none(); void select_all(); +void set_selection(int item, int value); +void list_invert_curitem_selection(); void move_curitem(int direction); void goto_home(); void goto_end(); -void highlight_line(WINDOW *win, int line); int selected_items(); void invert_selection(); -int list_current_item(); int list_is_empty(); +int list_get_curitem(); +void list_set_curitem(int i); int duplicate_item(); @@ -31,19 +57,11 @@ enum { }; #define LIST_TOP 3 -#define LIST_BOTTOM (LINES-2) +#define LIST_BOTTOM (LINES - 2) -#define LIST_LINES (LIST_BOTTOM-LIST_TOP) +#define LIST_LINES (LIST_BOTTOM - LIST_TOP) #define LIST_COLS COLS -#define NAMEPOS 2 -#define EMAILPOS opt_get_int(INT_EMAILPOS) -#define EXTRAPOS opt_get_int(INT_EXTRAPOS) - -#define NAMELEN (EMAILPOS-NAMEPOS -1) -#define EMAILLEN (EXTRAPOS-EMAILPOS -1) -#define EXTRALEN (COLS-EXTRAPOS) - -#define LAST_LIST_ITEM ( first_list_item + LIST_LINES - 1 ) +#define LAST_LIST_ITEM (first_list_item + LIST_LINES - 1) #endif diff --git a/misc.c b/misc.c index 9f0a0a3..d49980c 100644 --- a/misc.c +++ b/misc.c @@ -1,6 +1,6 @@ /* - * $Id: misc.c,v 1.21 2005/10/05 11:03:36 jheinonen Exp $ + * $Id: misc.c,v 1.23 2006/09/04 18:29:25 cduval Exp $ * * by JH * @@ -19,6 +19,7 @@ # include "config.h" #endif #include +#include "abook.h" #include "misc.h" #include "xmalloc.h" @@ -63,6 +64,19 @@ strtrim(char *s) return s; } +int +is_number(char *p) +{ + if(!p || !*p || (*p == '-' && !*++p)) + return 0; + + for(; *p; p++) + if(!isdigit(*p)) + return 0; + + return 1; +} + #ifdef HAVE_CONFIG_H # include "config.h" @@ -1076,3 +1090,189 @@ int main (void) #endif /* SNPRINTF_TEST */ #endif /* !HAVE_SNPRINTF */ + + + + +/* + * List handling functions + */ + +void +abook_list_append(abook_list **list, char *str) +{ + abook_list *tmp; + + if(!str) + return; + + for(tmp = *list; tmp && tmp->next; tmp = tmp->next) + ; + + if(tmp) { + tmp->next = xmalloc(sizeof(abook_list)); + tmp = tmp->next; + } else + tmp = *list = xmalloc(sizeof(abook_list)); + + tmp->data = xstrdup(str); + tmp->next = NULL; +} + +void +abook_list_free(abook_list **list) +{ + abook_list *prev = NULL, *tmp = *list; + + if(!list) + return; + + while(tmp) { + xfree(tmp->data); + prev = tmp; + tmp = tmp->next; + xfree(prev); + } + + *list = NULL; +} + +abook_list * +csv_to_abook_list(char *str) +{ + char *start, *p = str, *end; + abook_list *list = NULL; + + if(!str) + return NULL; + + SKIPWS(p); + start = end = p; + + while(*p) { + if(!strchr(", ", *p)) { + end = ++p; + continue; + } + + if((*p == ',') && (end - start)) { + abook_list_append(&list, xstrndup(start, end - start)); + p++; + SKIPWS(p); + start = end = p; + continue; + } + + p++; + } + if(end - start) + abook_list_append(&list, xstrndup(start, end - start)); + + return list; +} + +char * +abook_list_to_csv(abook_list *list) +{ + abook_list *tmp; + char *res = NULL; + + for(tmp = list; tmp; tmp = tmp->next) { + if(tmp == list) + res = xstrdup(tmp->data); + else { + res = xrealloc(res, strlen(res)+strlen(tmp->data)+2); + strcat(res, ","); + strcat(res, tmp->data); + } + } + + return res; +} + +void +abook_list_rotate(abook_list **list, enum rotate_dir dir) +{ + abook_list *tmp = *list; + + if(!tmp || !tmp->next) + return; + + switch(dir) { + case ROTATE_LEFT: + for(; tmp && tmp->next; tmp = tmp->next) + ; + + tmp->next = *list; + tmp = *list; + *list = (*list)->next; + tmp->next = NULL; + break; + case ROTATE_RIGHT: + for(; tmp && tmp->next && tmp->next->next; + tmp = tmp->next) + ; + + tmp->next->next = *list; + *list = tmp->next; + tmp->next = NULL; + break; + default: + assert(0); + } +} + +/* if str == NULL, deleting the list element */ +void +abook_list_replace(abook_list **list, int index, char *str) +{ + abook_list *cur, *prev; + int i = 0; + + cur = prev = *list; + + if((index == 0) && !str) { + *list = cur->next; + free(cur->data); + free(cur); + return; + } + + while(1) { + if(!cur) + return; + + if(i == index) + break; + + prev = cur; + cur = cur->next; + i++; + } + + if(str) { + free(cur->data); + cur->data = xstrdup(str); + } else { + prev->next = cur->next; + free(cur->data); + free(cur); + } +} + +abook_list * +abook_list_get(abook_list *list, int index) +{ + int i = 0; + + while(1) { + if(!list) + return NULL; + + if(i == index) + return list; + + i++; + list = list->next; + } +} diff --git a/misc.h b/misc.h index b40a4a1..fadd0ae 100644 --- a/misc.h +++ b/misc.h @@ -1,11 +1,23 @@ #ifndef _MISC_H #define _MISC_H +typedef struct abook_list_t { + char *data; + struct abook_list_t *next; +} abook_list; + +enum rotate_dir { + ROTATE_LEFT, + ROTATE_RIGHT +}; + char *revstr(char *str); char *strupper(char *str); char *strlower(char *str); char *strtrim(char *); +int is_number(char *s); + char *strdup_printf(const char *format, ... ); char *strconcat(const char *str, ...); @@ -20,6 +32,16 @@ int strwidth(const char *s); int bytes2width(const char *s, int width); +void abook_list_append(abook_list **list, char *str); +void abook_list_free(abook_list **list); +char *abook_list_to_csv(abook_list *list); +abook_list *csv_to_abook_list(char *str); +void abook_list_rotate(abook_list **list, enum rotate_dir dir); +void abook_list_replace(abook_list **list, int index, char *str); +abook_list *abook_list_get(abook_list *list, int index); +#define abook_list_delete(list, index) abook_list_replace(list, index, NULL) + + #ifdef HAVE_CONFIG_H # include "config.h" #endif @@ -34,3 +56,6 @@ int vsnprintf (char *str, size_t count, const char *fmt, va_list arg); #endif #endif + + + diff --git a/options.c b/options.c index 3b8c338..92d5670 100644 --- a/options.c +++ b/options.c @@ -1,6 +1,6 @@ /* - * $Id: options.c,v 1.27.4.1 2006/04/09 18:57:34 jheinonen Exp $ + * $Id: options.c,v 1.33 2006/09/06 08:48:33 jheinonen Exp $ * * by JH * @@ -17,6 +17,7 @@ #include "abook.h" #include "gettext.h" #include "misc.h" +#include "views.h" #include "xmalloc.h" #ifndef FALSE @@ -49,11 +50,7 @@ static struct option abook_vars[] = { { "autosave", OT_BOOL, BOOL_AUTOSAVE, TRUE }, { "show_all_emails", OT_BOOL, BOOL_SHOW_ALL_EMAILS, TRUE }, - { "emailpos", OT_INT, INT_EMAILPOS, 25 }, - { "extra_column", OT_STR, STR_EXTRA_COLUMN, UL "phone" }, - { "extra_alternative", OT_STR, STR_EXTRA_ALTERNATIVE, UL "-1" }, - { "extrapos", OT_INT, INT_EXTRAPOS, 65 }, - + { "index_format", OT_STR, STR_INDEX_FORMAT, UL " {name:22} {email:40} {phone:12|workphone|mobile}" }, { "mutt_command", OT_STR, STR_MUTT_COMMAND, UL "mutt" }, { "mutt_return_all_emails", OT_BOOL, BOOL_MUTT_RETURN_ALL_EMAILS, TRUE }, @@ -67,6 +64,7 @@ static struct option abook_vars[] = { { "use_ascii_only", OT_BOOL, BOOL_USE_ASCII_ONLY, FALSE }, { "add_email_prevent_duplicates", OT_BOOL, BOOL_ADD_EMAIL_PREVENT_DUPLICATES, FALSE }, + { "preserve_fields", OT_STR, STR_PRESERVE_FIELDS, UL "standard" }, { "sort_field", OT_STR, STR_SORT_FIELD, UL "nick" }, { "show_cursor", OT_BOOL, BOOL_SHOW_CURSOR, FALSE }, @@ -206,36 +204,87 @@ opt_line_remove_comments(char *p) } } -void -find_token_start(buffer *b) +/* After calling, + * - b->data points to the found token, or NULL is end of parsing + * - b->ptr points to the begining of next token + * + * If the TOKEN_ALLOC option is used, the original string is not mangled + * and memory is allocated for the token. + */ +static char * +get_token(buffer *b, int options) { + char quote = 0, c; + char *end = NULL; + assert(b); - for(; ISSPACE(*b -> ptr); b -> ptr ++); -} + SKIPWS(b->ptr); + if(*b->ptr && strchr("\"'", *b->ptr)) + quote = *(b->ptr++); + b->data = b->ptr; -void -find_token_end(buffer *b) -{ - assert(b); + while(1) { + if(!(c = *b->ptr)) { + end = b->ptr; + break; + } - for(find_token_start(b); *(b -> ptr); b -> ptr ++) { - if(ISSPACE(*(b -> ptr))) { + if(!quote && ( + ISSPACE(c) || + ((options & TOKEN_EQUAL) && (c == '=')) || + ((options & TOKEN_COMMA) && (c == ','))) + ) { + end = b->ptr; + break; + } else if(c == quote) { + quote = 0; + end = b->ptr++; break; } + + b->ptr++; + } + + if(quote) + return _("quote mismatch"); + + if(options & (TOKEN_EQUAL | TOKEN_COMMA)) + SKIPWS(b->ptr); /* whitespaces can precede the sign */ + + if((options & TOKEN_EQUAL) && (*b->ptr != '=')) + return _("no assignment character found"); + + if((options & TOKEN_COMMA) && *b->ptr && (*b->ptr != ',')) + return _("error in comma separated list"); + + if(b->ptr == b->data) { + b->data = NULL; + return NULL; /* no error, just end of parsing */ } + + if(options & TOKEN_ALLOC) /* freeing is the caller's responsibility */ + b->data = xstrndup(b->data, end - b->data); + else + *end = 0; + + b->ptr++; /* advance to next token */ + SKIPWS(b->ptr); + + return NULL; } static const char * -opt_set_set_option(char *var, char *p, struct option *opt) +opt_set_set_option(char *p, struct option *opt) { int len; - strtrim(p); + assert(p); + strtrim(p); len = strlen(p); - if(p[len - 1] == '\"' && *p == '\"') { + if(*p == '\"' && p[len - 1] == '\"') { if(len < 3) return _("invalid value"); p[len - 1] = 0; @@ -266,59 +315,142 @@ opt_set_set_option(char *var, char *p, struct option *opt) } static const char * -opt_parse_set(buffer *b) +opt_set_option(char *var, char *p) { int i; - char *p; - - find_token_start(b); - if((p = strchr(b -> ptr, '='))) - *p++ = 0; - else - return _("invalid value assignment"); - strtrim(b -> ptr); + assert(var); + assert(p); - for(i = 0;abook_vars[i].option; i++) - if(!strcmp(abook_vars[i].option, b -> ptr)) - return opt_set_set_option(b -> ptr, p, &abook_vars[i]); + for(i = 0; abook_vars[i].option; i++) + if(!strcmp(abook_vars[i].option, var)) + return opt_set_set_option(p, &abook_vars[i]); return _("unknown option"); } -#include "database.h" /* needed for change_custom_field_name */ +static int +check_options() +{ + char *str; + int err = 0; + + str = opt_get_str(STR_PRESERVE_FIELDS); + if(strcasecmp(str, "all") && strcasecmp(str, "none") && + strcasecmp(str, "standard")) { + fprintf(stderr, _("valid values for the 'preserve_fields' " + "option are 'all', 'standard' " + "(default), and 'none'\n")); + restore_default(&abook_vars[STR_PRESERVE_FIELDS]); + err++; + } + str = opt_get_str(STR_ADDRESS_STYLE); + if(strcasecmp(str, "eu") && strcasecmp(str, "uk") && + strcasecmp(str, "us")) { + fprintf(stderr, _("valid values for the 'address_style' " + "option are 'eu' (default), 'uk', " + "and 'us'\n")); + restore_default(&abook_vars[STR_ADDRESS_STYLE]); + err++; + } + + return err; +} + +/* + * syntax: set
%s