17258N/A===================================================================
17258N/A+/* Solaris Trusted Extensions GNOME desktop library.
17258N/A+ Copyright (C) 2009 Sun Microsystems, Inc. All Rights Reserved.
17258N/A+ The contents of this library are subject to the terms of the
17258N/A+ GNU Lesser General Public License version 2 (the "License")
17258N/A+ as published by the Free Software Foundation. You may not use
17258N/A+ this library except in compliance with the License.
17258N/A+ You should have received a copy of the License along with this
17258N/A+ library; see the file COPYING. If not,you can obtain a copy
17258N/A+ to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17258N/A+ Boston, MA 02111-1307, USA. See the License for specific language
17258N/A+ governing permissions and limitations under the License.
17258N/A+ m_label_t *lower = NULL, *upper = NULL, *def = NULL, *label = NULL;
17258N/A+ char *min = NULL, *max = NULL, *defstr = NULL, *accredcheck = NULL;
17258N/A+ char *modestr = NULL, *format = NULL, *title = NULL, *text=NULL;
17258N/A+ const GOptionEntry options [] = {
17258N/A+ { "min", 'n', 0, G_OPTION_ARG_STRING, &min,
17258N/A+ "Minimim Label (Required)", "label string" },
17258N/A+ { "max", 'x', 0, G_OPTION_ARG_STRING, &max,
17258N/A+ "Maximum Label (Required)", "label string" },
17258N/A+ { "default", 'd', 0, G_OPTION_ARG_STRING, &defstr,
17258N/A+ "Default Selected Label", "label string" },
17258N/A+ { "accredcheck", 'a', 0, G_OPTION_ARG_STRING, &accredcheck,
17258N/A+ "Enable Accreditation checking", "[yes|no]" },
17258N/A+ { "mode", 'm', 0, G_OPTION_ARG_STRING, &modestr,
17258N/A+ "Clearance or Sensitivity mode", "[clearance|sensitivity]" },
17258N/A+ { "format", 'f', 0, G_OPTION_ARG_STRING, &format,
17258N/A+ "Internal or Human Readable format", "[internal|human]" },
17258N/A+ { "title", 'i', 0, G_OPTION_ARG_STRING, &title,
17258N/A+ { "text", 't', 0, G_OPTION_ARG_STRING, &text,
17258N/A+ "Operation description", "text" },
17258N/A+ g_printerr ("This command is only available if the system is "
17258N/A+ "configured with Trusted Extensions\n");
17258N/A+ context = g_option_context_new (NULL);
17258N/A+ g_option_context_add_main_entries (context, options, NULL);
17258N/A+ if (!g_option_context_parse (context, &argc, &argv, &error)) {
17258N/A+ g_printerr ("Could not parse arguments: %s\n", error->message);
17258N/A+ g_printerr ("You must specify both min and max labels\n\n%s",
17258N/A+ g_option_context_get_help (context, TRUE, NULL));
17258N/A+ g_option_context_free (context);
17258N/A+ if (modestr && strncmp (modestr, "clearance", 9) == 0) {
17258N/A+ if (format && strncmp (format, "human", 8) == 0) {
17258N/A+ if (accredcheck && strncmp (accredcheck, "yes", 3) == 0) {
17258N/A+ flags = L_DEFAULT | L_CHECK_AR;
17258N/A+ if (str_to_label (min, &lower, label_type, flags, &err) < 0) {
17258N/A+ g_printerr ("%s: Can not convert minimum label\n", argv[0]);
17258N/A+ g_printerr ("Label is outside the accreditation range");
17258N/A+ if (str_to_label (max, &upper, label_type, flags, &err) < 0) {
17258N/A+ g_printerr ("%s: Can not convert maximum label\n", argv[0]);
17258N/A+ g_printerr ("Label is outside the accreditation range");
17258N/A+ if (str_to_label (defstr, &def, label_type, flags, &err)<0){
17258N/A+ g_printerr ("%s: Can not convert default label\n", argv[0]);
17258N/A+ g_printerr ("Label is outside the accreditation range");
17258N/A+ lbuilder = g_object_new (GNOME_TYPE_LABEL_BUILDER, "mode", mode,
17258N/A+ "message", text ? text : "Select a Label",
17258N/A+ "lower", lower, "upper", upper, NULL);
17258N/A+ gtk_window_set_title (GTK_WINDOW (lbuilder),
17258N/A+ title ? title : "Label Selector");
17258N/A+ g_object_set (G_OBJECT (lbuilder), "sl", def, NULL);
17258N/A+ gtk_widget_show_all (lbuilder);
17258N/A+ switch (gtk_dialog_run (GTK_DIALOG (lbuilder))) {
17258N/A+ g_object_get (G_OBJECT (lbuilder), "sl", &label, NULL);
17258N/A+ if (label_to_str (label, &labelstr, format_flags, DEF_NAMES<0)){
17258N/A+ g_printerr ("%s: Can not convert selected label",
17258N/A+ gtk_widget_destroy (GTK_WIDGET (lbuilder));
17258N/A+ gtk_widget_destroy (GTK_WIDGET (lbuilder));
17258N/A===================================================================
17258N/A+bin_PROGRAMS = tgnome-selectlabel