diff options
author | Vincent Untz <vuntz@novell.com> | 2008-11-13 15:32:57 +0100 |
---|---|---|
committer | Vincent Untz <vuntz@novell.com> | 2008-11-13 15:32:57 +0100 |
commit | 40726ce8d8abb6cb53fc2e1b1890ade9b0161bdd (patch) | |
tree | f0bb2f6c7c0946f5c5ad694227fc746688c4cf15 | |
parent | ec0e0de5fb523c055ce02e96450ffcc087e38f80 (diff) |
Implement _cph_cups_is_printer_name_valid()
Based on the checks done in s-c-p.
-rw-r--r-- | src/cups.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -198,10 +198,21 @@ cph_cups_new (void) static gboolean _cph_cups_is_printer_name_valid (const char *name) { + int i; + if (!name || name[0] == '\0') return FALSE; - /* FIXME: what's a valid printer name? No space/tabs, etc. */ + /* only printable characters, no space, no /, no # */ + for (i = 0; i < strlen (name); i++) { + if (!g_ascii_isprint (name[i])) + return FALSE; + if (g_ascii_isspace (name[i])) + return FALSE; + if (name[i] == '/' || name[i] == '#') + return FALSE; + } + return TRUE; } |