static void compile_function_list(char *order, sort_function_type **Functions) /*{{{*/
{
   char buf[256];
   unsigned int nth=0;
   
   while (*Functions != NULL)
     {
	sort_function_type *next = (*Functions)->next;
	SLFREE (*Functions);
	*Functions = next;
     }
   
   if ((order == NULL) || !(*order)) return;
   
   while (-1 != SLextract_list_element (order, nth, ',', buf, sizeof(buf)))
     {
	if (! slrn_case_strcmp((unsigned char*)buf, (unsigned char*)"Subject"))
	  add_sort_function(Functions, header_subject_cmp, isupper(buf[0]));
	else if (! slrn_case_strcmp((unsigned char*)buf, (unsigned char*)"Score"))
	  add_sort_function(Functions, header_score_cmp, isupper(buf[0]));
	else if (! slrn_case_strcmp((unsigned char*)buf, (unsigned char*)"Highscore"))
	  add_sort_function(Functions, header_highscore_cmp, isupper(buf[0]));
	else if (! slrn_case_strcmp((unsigned char*)buf, (unsigned char*)"Date"))
	  add_sort_function(Functions, header_date_cmp, isupper(buf[0]));
	else if (! slrn_case_strcmp((unsigned char*)buf, (unsigned char*)"Author"))
	  add_sort_function(Functions, header_author_cmp, isupper(buf[0]));
	else if (! slrn_case_strcmp((unsigned char*)buf, (unsigned char*)"Lines"))
	  add_sort_function(Functions, header_lines_cmp, isupper(buf[0]));
	else if (! slrn_case_strcmp((unsigned char*)buf, (unsigned char*)"Number"))
	  add_sort_function(Functions, header_num_cmp, isupper(buf[0]));
	else if (! slrn_case_strcmp((unsigned char*)buf, (unsigned char*)"Id"))
	  add_sort_function(Functions, header_msgid_cmp, isupper(buf[0]));
	else if (! slrn_case_strcmp((unsigned char*)buf, (unsigned char*)"Body"))
	  add_sort_function(Functions, header_has_body_cmp, isupper(buf[0]));
	else /* Nonexistant sorting method */
	  {
	     slrn_error(_("Can't sort according to `%s'"), buf);
	  }
	
	nth++;
     } /* while (...) */
}
Exemple #2
0
char *SLpath_find_file_in_path (SLFUTURE_CONST char *path, SLFUTURE_CONST char *name)
{
   unsigned int max_path_len;
   unsigned int this_path_len;
   char *file, *dir;
   SLCONST char *p;
   unsigned int nth;

   if ((path == NULL) || (*path == 0)
       || (name == NULL) || (*name == 0))
     return NULL;

   if (is_relatively_absolute (name))
     {
	if (0 == SLpath_file_exists (name))
	  return NULL;
	return SLmake_string (name);
     }

   /* Allow "." to mean the current directory on all systems */
   if ((path[0] == '.') && (path[1] == 0))
     {
	if (0 == SLpath_file_exists (name))
	  return NULL;
	return SLpath_dircat (THIS_DIR_STRING, name);
     }

   max_path_len = 0;
   this_path_len = 0;
   p = path;
   while (*p != 0)
     {
	if (*p++ == Path_Delimiter)
	  {
	     if (this_path_len > max_path_len) max_path_len = this_path_len;
	     this_path_len = 0;
	  }
	else this_path_len++;
     }
   if (this_path_len > max_path_len) max_path_len = this_path_len;
   max_path_len++;

   if (NULL == (dir = (char *)SLmalloc (max_path_len)))
     return NULL;

   nth = 0;
   while (-1 != SLextract_list_element ((char *) path, nth, Path_Delimiter,
					dir, max_path_len))
     {
	nth++;
	if (*dir == 0)
	  continue;

	if (NULL == (file = SLpath_dircat (dir, name)))
	  {
	     SLfree (dir);
	     return NULL;
	  }

	if (1 == SLpath_file_exists (file))
	  {
	     SLfree (dir);
	     return file;
	  }

	SLfree (file);
     }

   SLfree (dir);
   return NULL;
}