/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * * Copyright (C) 2007-2008 Richard Hughes * * Licensed under the GNU General Public License Version 2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** * SECTION:pk-common * @short_description: Common utility functions for PackageKit * * This file contains functions that may be useful. */ #include "config.h" #include #include #include #include #include #include #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #include "egg-debug.h" #include "egg-string.h" /** * egg_strnumber: * @text: The text the validate * * Tests a string to see if it is a number. Both positive and negative numbers * are allowed. * * Return value: %TRUE if the string represents a numeric value **/ gboolean egg_strnumber (const gchar *text) { guint i; guint length; /* check explicitly */ if (egg_strzero (text)) return FALSE; /* max length is 10 */ length = egg_strlen (text, 10); if (length == 10) { egg_warning ("input too long: %s", text); return FALSE; } for (i=0; i