Ejemplo n.º 1
0
Archivo: dir.c Proyecto: CTU-OSP/mc
int
sort_atime (file_entry_t * a, file_entry_t * b)
{
    int ad = MY_ISDIR (a);
    int bd = MY_ISDIR (b);

    if (ad == bd || panels_options.mix_all_files)
    {
        int result = a->st.st_atime < b->st.st_atime ? -1 : a->st.st_atime > b->st.st_atime;
        if (result != 0)
            return result * reverse;
        else
            return sort_name (a, b);
    }
    else
        return bd - ad;
}
Ejemplo n.º 2
0
Archivo: dir.c Proyecto: Chainie/mc
int
sort_ext (file_entry * a, file_entry * b)
{
    int r;
    int ad = MY_ISDIR (a);
    int bd = MY_ISDIR (b);

    if (ad == bd || panels_options.mix_all_files)
    {
        if (a->second_sort_key == NULL)
            a->second_sort_key = str_create_key (extension (a->fname), case_sensitive);
        if (b->second_sort_key == NULL)
            b->second_sort_key = str_create_key (extension (b->fname), case_sensitive);

        r = str_key_collate (a->second_sort_key, b->second_sort_key, case_sensitive);
        if (r)
            return r * reverse;
        else
            return sort_name (a, b);
    }
    else
        return bd - ad;
}
Ejemplo n.º 3
0
AirspaceSorter::AirspaceSorter(const Airspaces &airspaces,
                               const GeoPoint &Location,
                               const fixed distance_factor)
{
  airspaces.lock();
  m_airspaces_all.reserve(airspaces.size());

  for (Airspaces::AirspaceTree::const_iterator it = airspaces.begin();
       it != airspaces.end(); ++it) {

    AirspaceSelectInfo info;
    
    const AbstractAirspace &airspace = *it->get_airspace();

    info.airspace = &airspace;

    const GeoPoint closest_loc = airspace.closest_point(Location);
    const GeoVector vec(Location, closest_loc);

    info.Distance = vec.Distance*distance_factor;
    info.Direction = vec.Bearing;

    tstring Name = airspace.get_name_text(true);

    info.FourChars = 
      ((Name.c_str()[0] & 0xff) << 24)
      +((Name.c_str()[1] & 0xff) << 16)
      +((Name.c_str()[2] & 0xff) << 8)
      +((Name.c_str()[3] & 0xff));

    m_airspaces_all.push_back(info);
  }
  airspaces.unlock();

  sort_name(m_airspaces_all);
}
Ejemplo n.º 4
0
int main()
{
    char s[80];
    student a[50], key, res;
    unsigned ch, n, pos;
    n=0;
    do{
        puts("What would you like to do?");
        puts(" ( 0) Exit");
        puts(" ( 1) Enter details");
        puts(" ( 2) Show details");
        puts(" ( 3) Insert an element");
        puts(" ( 4) Delete an element");
        puts(" ( 5) Sort by Name");
        puts(" ( 6) Sort by City");
        puts(" ( 7) Sort by Roll");
        puts(" ( 8) Sort by Mark");
        puts(" ( 9) Search by Name");
        puts(" (10) Search by City");
        puts(" (11) Search by Roll");
        puts(" (12) Search by Mark");
        scanf(" %u%*c", &ch);
        switch(ch){
        case 0:
            puts("Bye!");
            break;
        case 1:
            n=accept(a, n);
            break;
        case 2:
            display(a, n);
            break;
        case 3:
            puts("Enter the following details:");
            printf(" - Name : ");
            gets(s);
            strcpy(key.name, s);

            printf(" - City : ");
            gets(s);
            strcpy(key.city, s);

            printf(" - Roll : ");
            scanf(" %u%*c", &key.roll);

            printf(" - Mark : ");
            scanf(" %u%*c", &key.mark);

            puts("Position?");
            scanf(" %u%*c", &pos);
            putchar('\n');

            insert(a, &n, pos, key);
            display(a, n);
            break;
        case 4:
            puts("Position?");
            scanf(" %u%*c", &pos);
            delet(a, &n, pos);
            display(a, n);
            break;
        case 5:
            sort_name(a, n);
            display(a, n);
            break;
        case 6:
            sort_city(a, n);
            display(a, n);
            break;
        case 7:
            sort_roll(a, n);
            display(a, n);
            break;
        case 8:
            sort_mark(a, n);
            display(a, n);
            break;
        case 9:
            puts("Name?");
            gets(s);
            res=srch_name(a, n, s);
            if(is_equal(res, error)) display_one(res);
            else puts("Not Found.");
            break;
        case 10:
            puts("City?");
            gets(s);
            res=srch_city(a, n, s);
            if(is_equal(res, error)) display_one(res);
            else puts("Not Found.");
            break;
        case 11:
            puts("Roll?");
            scanf(" %u%*c", &pos);
            res=srch_roll(a, n, pos);
            if(is_equal(res, error)) display_one(res);
            else puts("Not Found.");
            break;
        case 12:
            puts("Mark?");
            scanf(" %u%*c", &pos);
            res=srch_mark(a, n, pos);
            if(is_equal(res, error)) display_one(res);
            else puts("Not Found.");
            break;
        default:
            puts("Incorrect Choice!");
            break;
        }
        putchar('\n');
    } while(ch);
    return 0;
}
Ejemplo n.º 5
0
Archivo: setup.c Proyecto: mavit/alpine
/*----------------------------------------------------------------------
    Present pinerc data for manipulation

    Args: None

  Result: help edit certain pinerc fields.
  ---*/
void
option_screen(struct pine *ps, int edit_exceptions)
{
    char	    tmp[MAXPATH+1], *pval, **lval;
    int		    i, j, ln = 0, readonly_warning = 0;
    struct	    variable  *vtmp;
    CONF_S	   *ctmpa = NULL, *ctmpb, *first_line = NULL;
    FEATURE_S	   *feature;
    PINERC_S       *prc = NULL;
    SAVED_CONFIG_S *vsave;
    OPT_SCREEN_S    screen;
    int             expose_hidden_config, add_hidden_vars_title = 0;

    dprint((3, "-- option_screen --\n"));

    expose_hidden_config = F_ON(F_EXPOSE_HIDDEN_CONFIG, ps_global);
    treat_color_vars_as_text = expose_hidden_config;

    ew = edit_exceptions ? ps_global->ew_for_except_vars : Main;

    if(ps->restricted)
      readonly_warning = 1;
    else{
	switch(ew){
	  case Main:
	    prc = ps->prc;
	    break;
	  case Post:
	    prc = ps->post_prc;
	    break;
	  default:
	    break;
	}

	readonly_warning = prc ? prc->readonly : 1;
	if(prc && prc->quit_to_edit){
	    quit_to_edit_msg(prc);
	    treat_color_vars_as_text = 0;
	    return;
	}
    }

    ps->next_screen = SCREEN_FUN_NULL;

    mailcap_free(); /* free resources we won't be using for a while */

    if(ps->fix_fixed_warning)
      offer_to_fix_pinerc(ps);

    /*
     * First, find longest variable name
     */
    for(vtmp = ps->vars; vtmp->name; vtmp++){
	if(exclude_config_var(ps, vtmp, expose_hidden_config))
	  continue;

	if((i = utf8_width(pretty_var_name(vtmp->name))) > ln)
	  ln = i;
    }

    dprint((9, "initialize config list\n"));

    /*
     * Next, allocate and initialize config line list...
     */
    for(vtmp = ps->vars; vtmp->name; vtmp++){
	/*
	 * INCOMING_FOLDERS is currently the first of the normally
	 * hidden variables. Should probably invent a more robust way
	 * to keep this up to date.
	 */
	if(expose_hidden_config && vtmp == &ps->vars[V_INCOMING_FOLDERS])
	  add_hidden_vars_title = 1;

	if(exclude_config_var(ps, vtmp, expose_hidden_config))
	  continue;

	if(add_hidden_vars_title){

	    add_hidden_vars_title = 0;

	    new_confline(&ctmpa);		/* Blank line */
	    ctmpa->flags	       |= CF_NOSELECT | CF_B_LINE;

	    new_confline(&ctmpa)->var	= NULL;
	    ctmpa->help			= NO_HELP;
	    ctmpa->valoffset		= 2;
	    ctmpa->flags	       |= CF_NOSELECT;
	    ctmpa->value = cpystr("--- [ Normally hidden configuration options ] ---");

	    new_confline(&ctmpa);		/* Blank line */
	    ctmpa->flags	       |= CF_NOSELECT | CF_B_LINE;
	}

	if(vtmp->is_list)
	  lval  = LVAL(vtmp, ew);
	else
	  pval  = PVAL(vtmp, ew);

	new_confline(&ctmpa)->var = vtmp;
	if(!first_line)
	  first_line = ctmpa;

	ctmpa->valoffset = ln + 3;
	if(vtmp->is_list)
	  ctmpa->keymenu	 = &config_text_wshuf_keymenu;
	else
	  ctmpa->keymenu	 = &config_text_keymenu;
	  
	ctmpa->help	 = config_help(vtmp - ps->vars, 0);
	ctmpa->tool	 = text_tool;

	utf8_snprintf(tmp, sizeof(tmp), "%-*.100w =", ln, pretty_var_name(vtmp->name));
	tmp[sizeof(tmp)-1] = '\0';
	ctmpa->varname  = cpystr(tmp);
	ctmpa->varnamep = ctmpb = ctmpa;
	ctmpa->flags   |= CF_STARTITEM;
	if(vtmp == &ps->vars[V_FEATURE_LIST]){	/* special checkbox case */
	    char *this_sect, *new_sect;

	    ctmpa->flags		 |= CF_NOSELECT;
	    ctmpa->keymenu		  = &config_checkbox_keymenu;
	    ctmpa->tool			  = NULL;

	    /* put a nice delimiter before list */
	    new_confline(&ctmpa)->var = NULL;
	    ctmpa->varnamep		  = ctmpb;
	    ctmpa->keymenu		  = &config_checkbox_keymenu;
	    ctmpa->help			  = NO_HELP;
	    ctmpa->tool			  = checkbox_tool;
	    ctmpa->valoffset		  = feature_indent();
	    ctmpa->flags		 |= CF_NOSELECT;
	    ctmpa->value = cpystr("Set    Feature Name");

	    new_confline(&ctmpa)->var = NULL;
	    ctmpa->varnamep		  = ctmpb;
	    ctmpa->keymenu		  = &config_checkbox_keymenu;
	    ctmpa->help			  = NO_HELP;
	    ctmpa->tool			  = checkbox_tool;
	    ctmpa->valoffset		  = feature_indent();
	    ctmpa->flags		 |= CF_NOSELECT;
	    ctmpa->value = cpystr("---  ----------------------");

	    for(i = 0, this_sect = NULL; (feature = feature_list(i)); i++)
	      if((new_sect = feature_list_section(feature)) &&
		 (strcmp(new_sect, HIDDEN_PREF) != 0)){
		  if(this_sect != new_sect){
		      new_confline(&ctmpa)->var = NULL;
		      ctmpa->varnamep		= ctmpb;
		      ctmpa->keymenu		= &config_checkbox_keymenu;
		      ctmpa->help		= NO_HELP;
		      ctmpa->tool		= checkbox_tool;
		      ctmpa->valoffset		= 2;
		      ctmpa->flags	       |= (CF_NOSELECT | CF_STARTITEM);
		      snprintf(tmp, sizeof(tmp), "[ %s ]", this_sect = new_sect);
		      tmp[sizeof(tmp)-1] = '\0';
		      ctmpa->value = cpystr(tmp);
		  }

		  new_confline(&ctmpa)->var = vtmp;
		  ctmpa->varnamep	    = ctmpb;
		  ctmpa->keymenu	    = &config_checkbox_keymenu;
		  ctmpa->help		    = config_help(vtmp-ps->vars,
							  feature->id);
		  ctmpa->tool		    = checkbox_tool;
		  ctmpa->valoffset	    = feature_indent();
		  ctmpa->varmem		    = i;
		  ctmpa->value		    = pretty_value(ps, ctmpa);
	      }
	}
	else if(standard_radio_var(ps, vtmp)){
	    standard_radio_setup(ps, &ctmpa, vtmp, NULL);
	}
	else if(vtmp == &ps->vars[V_SORT_KEY]){ /* radio case */
	    SortOrder def_sort;
	    int       def_sort_rev;

	    ctmpa->flags       |= CF_NOSELECT;
	    ctmpa->keymenu      = &config_radiobutton_keymenu;
	    ctmpa->tool		= NULL;

	    /* put a nice delimiter before list */
	    new_confline(&ctmpa)->var = NULL;
	    ctmpa->varnamep		  = ctmpb;
	    ctmpa->keymenu		  = &config_radiobutton_keymenu;
	    ctmpa->help			  = NO_HELP;
	    ctmpa->tool			  = radiobutton_tool;
	    ctmpa->valoffset		  = 12;
	    ctmpa->flags		 |= CF_NOSELECT;
	    ctmpa->value = cpystr("Set    Sort Options");

	    new_confline(&ctmpa)->var = NULL;
	    ctmpa->varnamep	      = ctmpb;
	    ctmpa->keymenu	      = &config_radiobutton_keymenu;
	    ctmpa->help		      = NO_HELP;
	    ctmpa->tool		      = radiobutton_tool;
	    ctmpa->valoffset	      = 12;
	    ctmpa->flags             |= CF_NOSELECT;
	    ctmpa->value = cpystr("---  ----------------------");

	    decode_sort(pval, &def_sort, &def_sort_rev, 0);

	    for(j = 0; j < 2; j++){
		for(i = 0; ps->sort_types[i] != EndofList; i++){
		    new_confline(&ctmpa)->var = vtmp;
		    ctmpa->varnamep	      = ctmpb;
		    ctmpa->keymenu	      = &config_radiobutton_keymenu;
		    ctmpa->help		      = config_help(vtmp - ps->vars, 0);
		    ctmpa->tool		      = radiobutton_tool;
		    ctmpa->valoffset	      = 12;
		    ctmpa->varmem	      = i + (j * EndofList);
		    ctmpa->value	      = pretty_value(ps, ctmpa);
		}
	    }
	}
        else if(vtmp == &ps->vars[V_THREAD_SORT_KEY]){ /* radio case */
            SortOrder thread_def_sort;
            int       thread_def_sort_rev, lv;

            ctmpa->flags       |= CF_NOSELECT;
            ctmpa->keymenu      = &config_radiobutton_keymenu;
            ctmpa->tool         = NULL;

            /* put a nice delimiter before list */
            new_confline(&ctmpa)->var = NULL;
            ctmpa->varnamep               = ctmpb;
            ctmpa->keymenu                = &config_radiobutton_keymenu;
            ctmpa->help                   = NO_HELP;
            ctmpa->tool                   = radiobutton_tool;
            ctmpa->valoffset              = 12;
            ctmpa->flags                 |= CF_NOSELECT;
            ctmpa->value = cpystr("Set    Thread Sort Options");

            new_confline(&ctmpa)->var = NULL;
            ctmpa->varnamep           = ctmpb;
            ctmpa->keymenu            = &config_radiobutton_keymenu;
            ctmpa->help               = NO_HELP;
            ctmpa->tool               = radiobutton_tool;
            ctmpa->valoffset          = 12;
            ctmpa->flags             |= CF_NOSELECT;
            ctmpa->value = cpystr("---  ----------------------");
  
            /* find longest value's name */
            for(lv = 0, i = 0; ps->sort_types[i] != EndofList; i++)
              if(lv < (j = strlen(sort_name(ps->sort_types[i]))))
                lv = j;

            decode_sort(pval, &thread_def_sort, &thread_def_sort_rev, 1);

            for(j = 0; j < 2; j++){
                for(i = 0; ps->sort_types[i] != EndofList; i++){
		  if (allowed_thread_key(ps->sort_types[i])){
                    new_confline(&ctmpa)->var = vtmp;
                    ctmpa->varnamep           = ctmpb;
                    ctmpa->keymenu            = &config_radiobutton_keymenu;
                    ctmpa->help               = config_help(vtmp - ps->vars, 0);
                    ctmpa->tool               = radiobutton_tool;
                    ctmpa->valoffset          = 12;
                    ctmpa->varmem             = i + (j * EndofList);
                    ctmpa->value              = pretty_value(ps, ctmpa);
		  }
                }
            }
        }
	else if(vtmp == &ps->vars[V_USE_ONLY_DOMAIN_NAME]){ /* yesno case */
	    ctmpa->keymenu = &config_yesno_keymenu;
	    ctmpa->tool	   = yesno_tool;
	    ctmpa->value   = pretty_value(ps, ctmpa);
	}
	else if(vtmp == &ps->vars[V_LITERAL_SIG]){
	    ctmpa->tool    = litsig_text_tool;
	    ctmpa->value   = pretty_value(ps, ctmpa);
	}
	else if(vtmp == &ps->vars[V_INBOX_PATH]){
	    ctmpa->tool    = inbox_path_text_tool;
	    ctmpa->value   = pretty_value(ps, ctmpa);
	}
	else if(vtmp == &ps->vars[V_POST_CHAR_SET]
#ifndef _WINDOWS
		|| vtmp == &ps->vars[V_CHAR_SET]
	        || vtmp == &ps->vars[V_KEY_CHAR_SET]
#endif /* !_WINDOWS */
		|| vtmp == &ps->vars[V_UNK_CHAR_SET]){
	    ctmpa->keymenu = &config_text_to_charsets_keymenu;
	    ctmpa->tool    = to_charsets_text_tool;
	    ctmpa->value   = pretty_value(ps, ctmpa);
	}
	else if(vtmp->is_list){
	    int (*t_tool)(struct pine *, int, CONF_S **, unsigned);
	    struct key_menu *km;

	    t_tool = NULL;
	    km = NULL;
	    if(vtmp == &ps->vars[V_INCCHECKLIST]){
		t_tool = incoming_monitoring_list_tool;
		km     = &config_text_keymenu;
	    }
	    else if(vtmp == &ps->vars[V_PERMLOCKED]){
		t_tool = stayopen_list_tool;
		km     = &config_text_wshufandfldr_keymenu;
	    }

	    if(lval){
		for(i = 0; lval[i]; i++){
		    if(i)
		      (void)new_confline(&ctmpa);

		    ctmpa->var       = vtmp;
		    ctmpa->varmem    = i;
		    ctmpa->valoffset = ln + 3;
		    ctmpa->value     = pretty_value(ps, ctmpa);
		    ctmpa->keymenu   = km ? km : &config_text_wshuf_keymenu;
		    ctmpa->help      = config_help(vtmp - ps->vars, 0);
		    ctmpa->tool      = t_tool ? t_tool : text_tool;
		    ctmpa->varnamep  = ctmpb;
		}
	    }
	    else{
		ctmpa->varmem = 0;
		ctmpa->value  = pretty_value(ps, ctmpa);
		ctmpa->tool   = t_tool ? t_tool : text_tool;
		ctmpa->keymenu = km ? km : &config_text_wshuf_keymenu;
	    }
	}
	else{
	    if(vtmp == &ps->vars[V_FILLCOL]
	       || vtmp == &ps->vars[V_SLEEP]
	       || vtmp == &ps->vars[V_QUOTE_SUPPRESSION]
	       || vtmp == &ps->vars[V_OVERLAP]
	       || vtmp == &ps->vars[V_MAXREMSTREAM]
	       || vtmp == &ps->vars[V_MARGIN]
	       || vtmp == &ps->vars[V_DEADLETS]
	       || vtmp == &ps->vars[V_NMW_WIDTH]
	       || vtmp == &ps->vars[V_STATUS_MSG_DELAY]
	       || vtmp == &ps->vars[V_ACTIVE_MSG_INTERVAL]
	       || vtmp == &ps->vars[V_MAILCHECK]
	       || vtmp == &ps->vars[V_MAILCHECKNONCURR]
	       || vtmp == &ps->vars[V_MAILDROPCHECK]
	       || vtmp == &ps->vars[V_NNTPRANGE]
	       || vtmp == &ps->vars[V_TCPOPENTIMEO]
	       || vtmp == &ps->vars[V_TCPREADWARNTIMEO]
	       || vtmp == &ps->vars[V_TCPWRITEWARNTIMEO]
	       || vtmp == &ps->vars[V_TCPQUERYTIMEO]
	       || vtmp == &ps->vars[V_RSHOPENTIMEO]
	       || vtmp == &ps->vars[V_SSHOPENTIMEO]
	       || vtmp == &ps->vars[V_INCCHECKTIMEO]
	       || vtmp == &ps->vars[V_INCCHECKINTERVAL]
	       || vtmp == &ps->vars[V_INC2NDCHECKINTERVAL]
	       || vtmp == &ps->vars[V_USERINPUTTIMEO]
	       || vtmp == &ps->vars[V_REMOTE_ABOOK_VALIDITY]
	       || vtmp == &ps->vars[V_REMOTE_ABOOK_HISTORY])
	      ctmpa->flags |= CF_NUMBER;

	    ctmpa->value = pretty_value(ps, ctmpa);
	}
    }

    dprint((9, "add hidden features\n"));

    /* add the hidden features */
    if(expose_hidden_config){
	char *new_sect;

	new_confline(&ctmpa);		/* Blank line */
	ctmpa->flags	       |= CF_NOSELECT | CF_B_LINE;

	new_confline(&ctmpa)->var	= NULL;
	ctmpa->help			= NO_HELP;
	ctmpa->valoffset		= 2;
	ctmpa->flags	       |= CF_NOSELECT;
	ctmpa->value = cpystr("--- [ Normally hidden configuration features ] ---");

	new_confline(&ctmpa);		/* Blank line */
	ctmpa->flags	       |= CF_NOSELECT | CF_B_LINE;

	vtmp = &ps->vars[V_FEATURE_LIST];

	ctmpa->flags		 |= CF_NOSELECT;
	ctmpa->keymenu		  = &config_checkbox_keymenu;
	ctmpa->tool			  = NULL;

	/* put a nice delimiter before list */
	new_confline(&ctmpa)->var = NULL;
	ctmpa->varnamep		  = ctmpb;
	ctmpa->keymenu		  = &config_checkbox_keymenu;
	ctmpa->help			  = NO_HELP;
	ctmpa->tool			  = checkbox_tool;
	ctmpa->valoffset		  = feature_indent();
	ctmpa->flags		 |= CF_NOSELECT;
	ctmpa->value = cpystr("Set    Feature Name");

	new_confline(&ctmpa)->var = NULL;
	ctmpa->varnamep		  = ctmpb;
	ctmpa->keymenu		  = &config_checkbox_keymenu;
	ctmpa->help			  = NO_HELP;
	ctmpa->tool			  = checkbox_tool;
	ctmpa->valoffset		  = feature_indent();
	ctmpa->flags		 |= CF_NOSELECT;
	ctmpa->value = cpystr("---  ----------------------");

	for(i = 0; (feature = feature_list(i)); i++)
	  if((new_sect = feature_list_section(feature)) &&
	     (strcmp(new_sect, HIDDEN_PREF) == 0)){

	      new_confline(&ctmpa)->var	= vtmp;
	      ctmpa->varnamep		= ctmpb;
	      ctmpa->keymenu		= &config_checkbox_keymenu;
	      ctmpa->help		= config_help(vtmp-ps->vars,
						      feature->id);
	      ctmpa->tool		= checkbox_tool;
	      ctmpa->valoffset		= feature_indent();
	      ctmpa->varmem		= i;
	      ctmpa->value		= pretty_value(ps, ctmpa);
	  }
    }

    vsave = save_config_vars(ps, expose_hidden_config);
    first_line = first_sel_confline(first_line);

    memset(&screen, 0, sizeof(screen));
    screen.ro_warning = readonly_warning;
    /* TRANSLATORS: Print something1 using something2.
       "configuration" is something1 */
    switch(conf_scroll_screen(ps, &screen, first_line,
			      edit_exceptions ? CONFIG_SCREEN_TITLE_EXC
					      : CONFIG_SCREEN_TITLE,
			      _("configuration"), 0)){
      case 0:
	break;

      case 1:
	write_pinerc(ps, ew, WRP_NONE);
	break;
    
      case 10:
	revert_to_saved_config(ps, vsave, expose_hidden_config);
	if(prc)
	  prc->outstanding_pinerc_changes = 0;

	break;
      
      default:
	q_status_message(SM_ORDER,7,10,
	    "conf_scroll_screen bad ret, not supposed to happen");
	break;
    }

    pval = PVAL(&ps->vars[V_SORT_KEY], ew);
    if(vsave[V_SORT_KEY].saved_user_val.p && pval
       && strcmp(vsave[V_SORT_KEY].saved_user_val.p, pval)){
	if(!mn_get_mansort(ps_global->msgmap)){
	    clear_index_cache(ps_global->mail_stream, 0);
	    reset_sort_order(SRT_VRB);
	}
    }

    pval = PVAL(&ps->vars[V_THREAD_SORT_KEY], ew);
    if(vsave[V_THREAD_SORT_KEY].saved_user_val.p && pval
       && strcmp(vsave[V_THREAD_SORT_KEY].saved_user_val.p, pval)){
      if(!mn_get_mansort(ps_global->msgmap)){
	  clear_index_cache(ps_global->mail_stream, 0);
          reset_sort_order(SRT_VRB);
      }
    }

    treat_color_vars_as_text = 0;
    free_saved_config(ps, &vsave, expose_hidden_config);
#ifdef _WINDOWS
    mswin_set_quit_confirm (F_OFF(F_QUIT_WO_CONFIRM, ps_global));
#endif
}
Ejemplo n.º 6
0
void main()
{
	FILE *fp,*fp1;
	int ch,flg=0,choice,i,j,len,setflg=0;
	char chaq,name[10],str[10][10];

	long int recsize;
	clrscr();
	menu:
	do
	{
		clrscr();
		printf( " \n\n\t\t\t PERSONAL CONTACTS \n\n" );

		printf( "\t\t様様様様様様様様   様様様様様様様様様\n\n" );
		printf( " \t\t\t1 -> ADD NEW CONTACT\n" );
		printf( " \t\t\t2 -> DISPLAY CONTACT\n" );
		printf( " \t\t\t3 -> SEARCH CONTACT\n" );
		printf( " \t\t\t4 -> DELETE CONTACT\n" );
		printf( " \t\t\t5 -> EXIT\n" );
		printf( "\n\t\t様様様様様様様様   様様様様様様様様様\n\n" );

		printf( "\nEnter ur choice......:   " );
		scanf( "%d",&ch);

		switch(ch)
		{
			case 1: fp=fopen("info2.dat","ab+");
					fp1=fopen("temp2.dat","ab+");
					clrscr();
					flg=0;
					printf( "\t\t\tADD NEW CONTACT INFO:\n" );
                    printf( "\n\t\t様様様様様様様様   様様様様様様様様様\n\n" );
					printf( "\n\nEnter the details....\n\n" );

					printf( "NAME :  " );
					flushall();
					scanf( "%[^\n]",p.name );
					strupr(p.name);

					printf( "\nADDRESS : " );
					flushall();
					scanf( "%[^\n]",p.addr);
					strupr(p.addr);

					printf( "\nTEL. No.(O) : " );
					flushall();
					scanf( "%[^\n]",&p.onum);

					printf( "\nTEL. No.(R) : " );
					flushall();
					scanf( "%[^\n]",&p.rnum);


					while(fread(&p1,sizeof(p1),1,fp)==1)
					{
						flg=0;
						if(strcmp(p1.name,p.name)<1)
						{
							fwrite(&p1,sizeof(p1),1,fp1);
							flg=1;
						}
						else
						 break;
					}
					recsize=sizeof(p);
					fwrite(&p,sizeof(p),1,fp1);
					if(flg!=1)
						fseek(fp,-recsize,SEEK_CUR);
					while(fread(&p1,sizeof(p1),1,fp)==1)
						fwrite(&p1,sizeof(p1),1,fp1);
					fclose(fp);
					fclose(fp1);

					remove("info2.dat");
					rename("temp2.dat","info2.dat");
					remove("temp2.dat");

					getch();

					clrscr();
					printf( "\n\n\n\n\n\n\n\n\n\n\t\t\t\t CONTACT ADDED\n" );
					getch();

					break;

			case 2: clrscr();
					printf( "\n\n\t\t1 -> ALL CONTACTS\n" );
					printf( "\t\t2 -> CHARECTERWISE\n" );
					printf( "\t\tENTER UR CHOICE....: " );
					scanf( "%d",&choice );

					switch(choice)
					{
						case 1: printf( "\t\t CONTACT INFORMATION\n\n" );


								for(chaq='A';chaq<='Z';chaq++)
								{
									sort_name(chaq);

									getch();
								}
								getch();
								goto menu;

						case 2: printf( "Enter the charecter: \n" );
								flushall();
								scanf( "%s",&chaq);
								strupr(&chaq);

								sort_name(chaq);
								getch();
								goto menu;

					}
					break;


			case 3: clrscr();
					fp=fopen("info2.dat","rb" );
					printf( "\n\n\n\t--------------------SEARCH CONTACT----------------------\n" );
					printf( "\n\nEnter the name : " );
					flushall();
					scanf( "%s",name);
					strupr(name);
					len=strlen(name);
					i=0;
					clrscr();
					printf( "\n\n\n\t--------------------CONTACT INFORMATION----------------------\n" );
					printf( "\t            -----------------------------------              \n" );
					printf( "\n\tNAME\t\tADDRESS\t\tOFFICE\t\tRECIDENCE\n" );
					printf( "\t            -----------------------------------              \n" );
					setflg=0;
					while(fread(&p,sizeof(p),1,fp)==1)
					{
						j=0;
						strcpy(str[i],p.name);
						for(j=0;j<len&&(str[i][j]==name[j]);j++);
						if(j==len)
						{
							printf( "\n\t%s\t\t%s\t\t%d\t\t%d\n",p.name,p.addr,p.onum,p.rnum);
							setflg=1;
						}
						i++;
					}
					if(setflg==0)
						printf( "\n\n\n\n\n\n\n\n\n\tSORRY!!!! SEARCH FAILED...... CONTACT NAMED %s DOES'NT EXIST!!!!\n",name );
					fclose(fp);
					getch();
					break;

			case 5: exit();

		}



	}while(ch!=5);
	getch();
}