summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Untz <vuntz@novell.com>2008-11-13 15:32:57 +0100
committerVincent Untz <vuntz@novell.com>2008-11-13 15:32:57 +0100
commit40726ce8d8abb6cb53fc2e1b1890ade9b0161bdd (patch)
treef0bb2f6c7c0946f5c5ad694227fc746688c4cf15
parentec0e0de5fb523c055ce02e96450ffcc087e38f80 (diff)
Implement _cph_cups_is_printer_name_valid()
Based on the checks done in s-c-p.
-rw-r--r--src/cups.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/cups.c b/src/cups.c
index ea387a9..b8d2a24 100644
--- a/src/cups.c
+++ b/src/cups.c
@@ -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;
}