index.html
Main Page
|
modules.html
Modules
|
namespaces.html
Namespace List
|
hierarchy.html
Class Hierarchy
|
annotated.html
Data Structures
|
dirs.html
Directories
|
files.html
File List
|
namespacemembers.html
Namespace Members
|
functions.html
Data Fields
|
pages.html
Related Pages
dir_000004.html
dbus
dbus-auth-util.c
00001
/* -*- mode: C; c-file-style: "gnu" -*- */
00002
/* dbus-auth-util.c Would be in dbus-auth.c, but only used for tests/bus
00003
*
00004
* Copyright (C) 2002, 2003, 2004 Red Hat Inc.
00005
*
00006
* Licensed under the Academic Free License version 2.1
00007
*
00008
* This program is free software; you can redistribute it and/or modify
00009
* it under the terms of the GNU General Public License as published by
00010
* the Free Software Foundation; either version 2 of the License, or
00011
* (at your option) any later version.
00012
*
00013
* This program is distributed in the hope that it will be useful,
00014
* but WITHOUT ANY WARRANTY; without even the implied warranty of
00015
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016
* GNU General Public License for more details.
00017
*
00018
* You should have received a copy of the GNU General Public License
00019
* along with this program; if not, write to the Free Software
00020
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021
*
00022
*/
00023
#include "dbus-internals.h"
00024
#include "dbus-test.h"
00025
#include "dbus-auth.h"
00026
00034
#ifdef DBUS_BUILD_TESTS
00035
#include "dbus-test.h"
00036
#include "dbus-auth-script.h"
00037
#include <stdio.h>
00038
00039
static
group__DBusTypes.html#ga2
dbus_bool_t
00040 process_test_subdir (
const
structDBusString.html
DBusString
*test_base_dir,
00041
const
char
*subdir)
00042 {
00043
structDBusString.html
DBusString
test_directory;
00044
structDBusString.html
DBusString
filename;
00045
structDBusDirIter.html
DBusDirIter
*dir;
00046
group__DBusTypes.html#ga2
dbus_bool_t
retval;
00047
structDBusError.html
DBusError
error;
00048
00049   retval =
group__DBusMacros.html#ga3
FALSE
;
00050   dir =
group__DBusMacros.html#ga4
NULL
;
00051
00052
if
(!
group__DBusString.html#ga6
_dbus_string_init
(&test_directory))
00053
group__DBusInternalsUtils.html#ga131
_dbus_assert_not_reached
(
"didn't allocate test_directory\n"
);
00054
00055
group__DBusString.html#ga7
_dbus_string_init_const
(&filename, subdir);
00056
00057
if
(!
group__DBusString.html#ga40
_dbus_string_copy
(test_base_dir, 0,
00058                           &test_directory, 0))
00059
group__DBusInternalsUtils.html#ga131
_dbus_assert_not_reached
(
"couldn't copy test_base_dir to test_directory"
);
00060
00061
if
(!
group__DBusInternalsUtils.html#ga90
_dbus_concat_dir_and_file
(&test_directory, &filename))
00062
group__DBusInternalsUtils.html#ga131
_dbus_assert_not_reached
(
"couldn't allocate full path"
);
00063
00064
group__DBusString.html#ga9
_dbus_string_free
(&filename);
00065
if
(!
group__DBusString.html#ga6
_dbus_string_init
(&filename))
00066
group__DBusInternalsUtils.html#ga131
_dbus_assert_not_reached
(
"didn't allocate filename string\n"
);
00067
00068
group__DBusErrors.html#ga0
dbus_error_init
(&error);
00069   dir =
group__DBusInternalsUtils.html#ga48
_dbus_directory_open
(&test_directory, &error);
00070
if
(dir ==
group__DBusMacros.html#ga4
NULL
)
00071     {
00072
group__DBusInternalsUtils.html#ga7
_dbus_warn
(
"Could not open %s: %s\n"
,
00073                   _dbus_string_get_const_data (&test_directory),
00074                   error.
structDBusError.html#o1
message
);
00075
group__DBusErrors.html#ga1
dbus_error_free
(&error);
00076
goto
failed;
00077     }
00078
00079   printf (
"Testing %s:\n"
, subdir);
00080
00081  next:
00082
while
(
group__DBusInternalsUtils.html#ga49
_dbus_directory_get_next_file
(dir, &filename, &error))
00083     {
00084
structDBusString.html
DBusString
full_path;
00085
00086
if
(!
group__DBusString.html#ga6
_dbus_string_init
(&full_path))
00087
group__DBusInternalsUtils.html#ga131
_dbus_assert_not_reached
(
"couldn't init string"
);
00088
00089
if
(!
group__DBusString.html#ga40
_dbus_string_copy
(&test_directory, 0, &full_path, 0))
00090
group__DBusInternalsUtils.html#ga131
_dbus_assert_not_reached
(
"couldn't copy dir to full_path"
);
00091
00092
if
(!
group__DBusInternalsUtils.html#ga90
_dbus_concat_dir_and_file
(&full_path, &filename))
00093
group__DBusInternalsUtils.html#ga131
_dbus_assert_not_reached
(
"couldn't concat file to dir"
);
00094
00095
if
(!
group__DBusString.html#ga0
_dbus_string_ends_with_c_str
(&filename,
".auth-script"
))
00096         {
00097           _dbus_verbose (
"Skipping non-.auth-script file %s\n"
,
00098                          _dbus_string_get_const_data (&filename));
00099
group__DBusString.html#ga9
_dbus_string_free
(&full_path);
00100
goto
next;
00101         }
00102
00103       printf (
"    %s\n"
, _dbus_string_get_const_data (&filename));
00104
00105
if
(!_dbus_auth_script_run (&full_path))
00106         {
00107
group__DBusString.html#ga9
_dbus_string_free
(&full_path);
00108
goto
failed;
00109         }
00110
else
00111
group__DBusString.html#ga9
_dbus_string_free
(&full_path);
00112     }
00113
00114
if
(
group__DBusErrors.html#ga5
dbus_error_is_set
(&error))
00115     {
00116
group__DBusInternalsUtils.html#ga7
_dbus_warn
(
"Could not get next file in %s: %s\n"
,
00117                   _dbus_string_get_const_data (&test_directory), error.message);
00118
group__DBusErrors.html#ga1
dbus_error_free
(&error);
00119
goto
failed;
00120     }
00121
00122   retval =
group__DBusMacros.html#ga2
TRUE
;
00123
00124  failed:
00125
00126
if
(dir)
00127
group__DBusInternalsUtils.html#ga50
_dbus_directory_close
(dir);
00128
group__DBusString.html#ga9
_dbus_string_free
(&test_directory);
00129
group__DBusString.html#ga9
_dbus_string_free
(&filename);
00130
00131
return
retval;
00132 }
00133
00134
static
group__DBusTypes.html#ga2
dbus_bool_t
00135 process_test_dirs (
const
char
*test_data_dir)
00136 {
00137
structDBusString.html
DBusString
test_directory;
00138
group__DBusTypes.html#ga2
dbus_bool_t
retval;
00139
00140   retval =
group__DBusMacros.html#ga3
FALSE
;
00141
00142
group__DBusString.html#ga7
_dbus_string_init_const
(&test_directory, test_data_dir);
00143
00144
if
(!process_test_subdir (&test_directory,
"auth"
))
00145
goto
failed;
00146
00147   retval =
group__DBusMacros.html#ga2
TRUE
;
00148
00149  failed:
00150
00151
group__DBusString.html#ga9
_dbus_string_free
(&test_directory);
00152
00153
return
retval;
00154 }
00155
00156
group__DBusTypes.html#ga2
dbus_bool_t
00157 _dbus_auth_test (
const
char
*test_data_dir)
00158 {
00159
00160
if
(test_data_dir ==
group__DBusMacros.html#ga4
NULL
)
00161
return
group__DBusMacros.html#ga2
TRUE
;
00162
00163
if
(!process_test_dirs (test_data_dir))
00164
return
group__DBusMacros.html#ga3
FALSE
;
00165
00166
return
group__DBusMacros.html#ga2
TRUE
;
00167 }
00168
00169
#endif
/* DBUS_BUILD_TESTS */
Generated on Tue Sep 13 01:28:06 2005 for D-BUS by
http://www.doxygen.org/index.html
doxygen
1.4.4
