src/cmd/fsexam/src/fsexam-history.h
changeset 149 0014c9b031e9
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 #ifndef _FSEXAM_HISTORY_
       
    28 #define _FSEXAM_HISTORY_
       
    29 
       
    30 #define HIST_LEN 100
       
    31 
       
    32 typedef struct _History_item
       
    33 {
       
    34     gint32    serial;           /* used by undo */
       
    35     ConvType  convtype;
       
    36     gint      from_encoding;
       
    37     gint      to_encoding;
       
    38     gchar     *uri;             /* always is uri */
       
    39 }Hist_item;
       
    40 
       
    41 /* 
       
    42  * defined to History_info in header file 
       
    43  *
       
    44  * 1) Empty state:
       
    45  *      head = 0;
       
    46  *      current = -1;
       
    47  *      last_serial = 0;
       
    48  *
       
    49  * 2) Only one element:
       
    50  *      head = 0;
       
    51  *      current = -1
       
    52  *
       
    53  * 3) Full
       
    54  *      current + 1 == head
       
    55  */
       
    56 struct _History_info
       
    57 {
       
    58     FILE      *fp;              /* FILE stream pointer for ~/.fsexam.history */
       
    59     GList     **hist_array;     /* the list of History_item */
       
    60     gint32    max_len;         /* The total length of history */
       
    61     gint32    head;             /* always point to NUL element as condition  */
       
    62     gint32    current;          /* the last used element */
       
    63     gint32    last_serial;
       
    64     gboolean  changed;
       
    65 };
       
    66 
       
    67 typedef struct _History_info Hist_info;
       
    68 
       
    69 /* 
       
    70  * to make life easier, history use uri internally 
       
    71  * both in disk and in memory 
       
    72  */
       
    73 
       
    74 Hist_info * fsexam_history_open (const gchar *filename, gint max_len);
       
    75 gboolean    fsexam_history_close (Hist_info *);
       
    76 void        fsexam_history_remove_last (Hist_info *);
       
    77 gint32      fsexam_history_get_serial (Hist_info *info);
       
    78 GList     * fsexam_history_get_last_list (Hist_info *info, ConvType *type);
       
    79 Hist_item * fsexam_history_search (Hist_info *info, 
       
    80                                    const gchar *path, 
       
    81                                    gboolean convname);
       
    82 void        fsexam_history_put (Hist_info *,
       
    83                                 ConvType convtype,
       
    84                                 const gchar *filename,
       
    85                                 gint from_encoding,
       
    86                                 gint to_encoding,
       
    87                                 gboolean same_serial);
       
    88 
       
    89 #endif