src/cmd/fsexam/src/fsexam-error.c
changeset 149 0014c9b031e9
parent 147 8c4ef02c14b8
equal deleted inserted replaced
148:91c620d9e52f 149:0014c9b031e9
       
     1 /*
       
     2  * CDDL HEADER START
       
     3  *
       
     4  * The contents of this file are subject to the terms of the
       
     5  * Common Development and Distribution License (the "License").
       
     6  * You may not use this file except in compliance with the License.
       
     7  *
       
     8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
       
     9  * or http://www.opensolaris.org/os/licensing.
       
    10  * See the License for the specific language governing permissions
       
    11  * and limitations under the License.
       
    12  *
       
    13  * When distributing Covered Code, include this CDDL HEADER in each
       
    14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
       
    15  * If applicable, add the following below this CDDL HEADER, with the
       
    16  * fields enclosed by brackets "[]" replaced with your own identifying
       
    17  * information: Portions Copyright [yyyy] [name of copyright owner]
       
    18  *
       
    19  * CDDL HEADER END
       
    20  */
       
    21 
       
    22 /*
       
    23  * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
       
    24  * Use is subject to license terms.
       
    25  */
       
    26 
       
    27 #include "fsexam-error.h"
       
    28 
       
    29 #include <stdio.h>
       
    30 #include <glib/gi18n.h>
       
    31 
       
    32 char *errmsg[] = {
       
    33     N_("Success"),                              /* ERR_OK */
       
    34     N_("File name is UTF-8 already"),           /* ERR_NAME_UTF8_ALREADY */
       
    35     N_("File content is UTF-8 already"),        /* ERR_CONTENT_UTF8_ALREADY */
       
    36     N_("New name is the same as old name"),     /* ERR_NAME_SAME */
       
    37 
       
    38     /* Error */
       
    39     "holder for ERR_ERROR",
       
    40     N_("File doesn't exist"),                   /* ERR_FILE_NONEXIST */
       
    41     N_("No Memory"),                            /* ERR_NO_MEMORY */
       
    42     N_("Invalid encoding index"),               /* ERR_ENCODING_INDEX_INVALID */
       
    43     N_("Can't open file"),                      /* ERR_CANNOT_OPEN */
       
    44     N_("Can't rename file"),                    /* ERR_CANNOT_RENAME */
       
    45     N_("Can't write file"),                     /* ERR_CANNOT_WRITE */
       
    46     N_("Given encoding list is not suitable"),  /* ERR_NO_PROPER_ENCODING */
       
    47     N_("Is not regular file"),                  /* ERR_NOT_REG_FILE */
       
    48     N_("Symlink target don't exist"),           /* ERR_SYMLINK_TARGET_NOEXIST */
       
    49     N_("Can't convert given file"),             /* ERR_CANNOT_CONVERT */
       
    50     N_("Can't read file"),                      /* ERR_CANNOT_READ */
       
    51     N_("No proper permission"),                     /* ERR_NO_RIGHTS */
       
    52     /* ERR_CANNOT_RM_SYMLINK */
       
    53     N_("Can't relink symbolic link which will break symbolic link"), 
       
    54     /* ERR_LOST_SYMLINK_FILE */
       
    55     N_("Have deleted symbolic link file, but can't recreate it"), 
       
    56     N_("Dryrun file format is invalid"),        /* ERR_DRYRUN_FILE_INVALID */
       
    57     N_("Can't get current directory"),          /* ERR_GET_CWD */
       
    58     N_("Can't change directory"),               /* ERR_CHDIR */
       
    59    
       
    60     /* Warning */
       
    61    "HOLDER for ERR_WARNING", 
       
    62     N_("No history information for current file"),   /* ERR_HIST_NO_ITEM  */
       
    63     N_("No given files or all files are UTF-8 already"), /* ERR_TREE_IS_EMPTY */
       
    64     /* ERR_NAME_EXIST */
       
    65     N_("Same name file exists, will append 'utf-8' as suffix"),
       
    66     N_("Skip hidden file"),                     /* ERR_IGNORE_HIDDEN_FILE */
       
    67     N_("Skip non-local file"),                  /* ERR_IGNORE_REMOTE_FILE */
       
    68     N_("Empty file"),                           /* ERR_EMPTY_FILE */
       
    69     N_("No parameters"),                        /* ERR_NO_PARAMS */
       
    70     N_("Error occurred during filtering"),      /* ERR_FILTER */
       
    71     N_("Don't support this kind of file type"), /* ERR_FILE_TYPE_NOT_SUPPORT */
       
    72     N_("Buffer overflow"),                      /* ERR_BUFFER_OVERFLOW */
       
    73     N_("Canceled the conversion"),              /* ERR_CANCEL_CONVERSION */
       
    74 
       
    75     /* Won't Log */
       
    76     "HOLDER for won't log",
       
    77     N_("Can't write dryrun result file"),       /* ERR_CANNOT_WRITE_DRYRUN */
       
    78     N_("Can't open dryrun result file"),        /* ERR_CANNOT_OPEN_DYRRUN */
       
    79     N_("Can't convert filename to URI"),        /* ERR_CANNOT_CONVERT_TO_URI */
       
    80 
       
    81     /* MISC*/
       
    82     N_("Unknown error occurred"),                /* ERR_MISC */
       
    83 };
       
    84 
       
    85 //TODO: store the errno in the system.
       
    86 ERROR_NO fsexam_errno = ERR_OK;
       
    87 
       
    88 const char *
       
    89 fsexam_error_get_msg ()
       
    90 {
       
    91     return _(errmsg[fsexam_errno]);
       
    92 }
       
    93 
       
    94 void
       
    95 _fsexam_perror (char *errnofile, int line, char *filename)
       
    96 {
       
    97     if (filename != NULL){
       
    98         printf (_("ERROR ==> %s:%d (%s): %s\n"), errnofile, line, 
       
    99                 filename, _(errmsg[fsexam_errno]));
       
   100         return;
       
   101     }
       
   102 
       
   103     printf (_("ERROR ==> %s:%d %s\n"), errnofile, line, _(errmsg[fsexam_errno]));
       
   104 
       
   105     return;
       
   106 }