Commit 8a3fd3b7 8a3fd3b7f0b7de2e039aa7ef9a5a4d2f8a393fdd by Sergey Poznyakoff

(print_file,print_dir): Rewrite using an

auxiliary function. Make sure the string is properly quoted if it
is not a valid atom.
1 parent 9ab1fd94
1 /* GNU Mailutils -- a suite of utilities for electronic mail 1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 1999, 2001, 2002, 2005 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001, 2002, 2005, 2006 Free Software Foundation, Inc.
3 3
4 GNU Mailutils is free software; you can redistribute it and/or modify 4 GNU Mailutils is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -313,38 +313,34 @@ list_file (const char *cwd, const char *ref, const char *pattern, ...@@ -313,38 +313,34 @@ list_file (const char *cwd, const char *ref, const char *pattern,
313 closedir (dirp); 313 closedir (dirp);
314 } 314 }
315 315
316 /* Make sure that the file name does not contain any undesirable
317 chars like "{}. If yes send it as a literal string. */
318 static void 316 static void
319 print_file (const char *ref, const char *file, const char *delim) 317 print_name (const char *ref, const char *file, const char *delim,
318 const char *attr)
320 { 319 {
321 char *name = mkfullname (ref, file, delim); 320 char *name = mkfullname (ref, file, delim);
322 if (strpbrk (file, "\"{}")) 321 if (strpbrk (name, "\"{}"))
323 { 322 {
324 util_out (RESP_NONE, "LIST (\\NoInferiors) \"%s\" {%d}", delim, 323 util_out (RESP_NONE, "LIST (%s) \"%s\" {%d}",
325 strlen (name)); 324 attr, delim, strlen (name));
326 util_send ("%s\r\n", name); 325 util_send ("%s\r\n", name);
327 } 326 }
327 else if (is_atom (name))
328 util_out (RESP_NONE, "LIST (%s) \"%s\" %s", attr, delim, name);
328 else 329 else
329 util_out (RESP_NONE, "LIST (\\NoInferiors) \"%s\" %s", delim, name); 330 util_out (RESP_NONE, "LIST (%s) \"%s\" \"%s\"", attr, delim, name);
330 free (name); 331 free (name);
331 } 332 }
332 333
333 /* Make sure that the file name does not contain any undesirable 334 static void
334 chars like "{}. If yes send it as a literal string. */ 335 print_file (const char *ref, const char *file, const char *delim)
336 {
337 print_name (ref, file, delim, "\\NoInferiors");
338 }
339
335 static void 340 static void
336 print_dir (const char *ref, const char *file, const char *delim) 341 print_dir (const char *ref, const char *file, const char *delim)
337 { 342 {
338 char *name = mkfullname (ref, file, delim); 343 print_name (ref, file, delim, "\\NoSelect");
339 if (strpbrk (file, "\"{}"))
340 {
341 util_out (RESP_NONE, "LIST (\\NoSelect) \"%s\" {%d}", delim,
342 strlen (name));
343 util_send ("%s\r\n", name);
344 }
345 else
346 util_out (RESP_NONE, "LIST (\\NoSelect) \"%s\" %s", delim, name);
347 free (name);
348 } 344 }
349 345
350 /* Calls the imap_matcher if a match found out the attribute. */ 346 /* Calls the imap_matcher if a match found out the attribute. */
......