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  * Copyright 2012, Daniil Lunev. All rights reserved.
  23  */
  24 
  25 #define SEPARATOR "="
  26 
  27 typedef struct menu_entry menu_entry;
  28 typedef struct menu_list menu_list;
  29 typedef enum cmd_id cmd_id;
  30 
  31 struct menu_entry {
  32         char entry_name[MAX_STRING_SIZE];
  33         char pool_label[MAX_STRING_SIZE];
  34         char pool_uuid[MAX_STRING_SIZE];
  35         char dataset[MAX_STRING_SIZE];
  36         char kernel[MAX_STRING_SIZE];
  37         char kernel_opts[MAX_STRING_SIZE];
  38         unsigned int modules_amount;
  39         char ** modules;
  40 };
  41 
  42 extern char default_entry[MAX_STRING_SIZE];
  43 extern char timeout[MAX_STRING_SIZE];
  44 extern char serial[MAX_STRING_SIZE];
  45 extern char terminal[MAX_STRING_SIZE];
  46 
  47 struct menu_list {
  48         unsigned int entry_number;
  49         menu_entry entry;
  50         menu_list * next;
  51 };
  52 
  53 enum cmd_id {
  54         CMD_ENTRY_NAME,
  55         CMD_POOL_LABEL,
  56         CMD_POOL_UUID,
  57         CMD_DATA_SET,
  58         CMD_KERNEL_PATH,
  59         CMD_KERNEL_OPTIONS,
  60         CMD_BA_PATH,
  61         CMD_DEFAULT,
  62         CMD_TIMEOUT,
  63         CMD_SERIAL,
  64         CMD_TERMINAL,
  65         CMD_UNKNOWN
  66 };
  67 
  68 extern const char * cmd_list[];
  69 
  70 void
  71 free_menu (menu_list ** menu);
  72 
  73 menu_list *
  74 parse_file (const char * file_name, int * entries_amount);
  75 
  76 void
  77 list_menu (menu_list * menu);
  78 
  79 menu_list *
  80 add_entry (menu_list ** menu, menu_list * entry);
  81 
  82 menu_list *
  83 clone_entry (menu_list  *entry);
  84 
  85 int
  86 delete_entry (menu_list ** menu, menu_list * del);
  87 
  88 menu_list *
  89 find_entry (menu_list * menu, menu_list * find);
  90 
  91 menu_list *
  92 enable_hyper (menu_list * entry);
  93 
  94 menu_list *
  95 disable_hyper (menu_list * entry);
  96 
  97 menu_list *
  98 get_entry_by_number (menu_list * menu, int number);