Blame Autest.c

Packit 56e0ee
/*
Packit 56e0ee
Packit 56e0ee
Copyright 1988, 1998  The Open Group
Packit 56e0ee
Packit 56e0ee
Permission to use, copy, modify, distribute, and sell this software and its
Packit 56e0ee
documentation for any purpose is hereby granted without fee, provided that
Packit 56e0ee
the above copyright notice appear in all copies and that both that
Packit 56e0ee
copyright notice and this permission notice appear in supporting
Packit 56e0ee
documentation.
Packit 56e0ee
Packit 56e0ee
The above copyright notice and this permission notice shall be included in
Packit 56e0ee
all copies or substantial portions of the Software.
Packit 56e0ee
Packit 56e0ee
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Packit 56e0ee
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Packit 56e0ee
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
Packit 56e0ee
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
Packit 56e0ee
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
Packit 56e0ee
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Packit 56e0ee
Packit 56e0ee
Except as contained in this notice, the name of The Open Group shall not be
Packit 56e0ee
used in advertising or otherwise to promote the sale, use or other dealings
Packit 56e0ee
in this Software without prior written authorization from The Open Group.
Packit 56e0ee
Packit 56e0ee
*/
Packit 56e0ee
Packit 56e0ee
#ifdef HAVE_CONFIG_H
Packit 56e0ee
#include <config.h>
Packit 56e0ee
#endif
Packit 56e0ee
#include <X11/Xauth.h>
Packit 56e0ee
#include <stdio.h>
Packit 56e0ee
#include <stdlib.h>
Packit 56e0ee
Packit 56e0ee
int
Packit 56e0ee
main (int argc, char **argv)
Packit 56e0ee
{
Packit 56e0ee
    Xauth   test_data;
Packit 56e0ee
    char    *name = "XAU-TEST-1";
Packit 56e0ee
    char    *data = "Do not begin the test until instructed to do so.";
Packit 56e0ee
    char    *file = NULL;
Packit 56e0ee
    int	    state = 0;
Packit 56e0ee
    FILE    *output;
Packit 56e0ee
Packit 56e0ee
    while (*++argv) {
Packit 56e0ee
	if (!strcmp (*argv, "-file"))
Packit 56e0ee
	    file = *++argv;
Packit 56e0ee
	else if (state == 0) {
Packit 56e0ee
	    name = *argv;
Packit 56e0ee
	    ++state;
Packit 56e0ee
	} else if (state == 1) {
Packit 56e0ee
	    data = *argv;
Packit 56e0ee
	    ++state;
Packit 56e0ee
	}
Packit 56e0ee
    }
Packit 56e0ee
    test_data.family = 0;
Packit 56e0ee
    test_data.address_length = 0;
Packit 56e0ee
    test_data.address = "";
Packit 56e0ee
    test_data.number_length = 0;
Packit 56e0ee
    test_data.number = "";
Packit 56e0ee
    test_data.name_length = strlen (name);
Packit 56e0ee
    test_data.name = name;
Packit 56e0ee
    test_data.data_length = strlen (data);
Packit 56e0ee
    test_data.data = data;
Packit 56e0ee
    if (!file) {
Packit 56e0ee
	output = tmpfile();
Packit 56e0ee
    } else {
Packit 56e0ee
	output = fopen (file, "w");
Packit 56e0ee
    }
Packit 56e0ee
    if (output) {
Packit 56e0ee
	state = XauWriteAuth (output, &test_data);
Packit 56e0ee
	fclose (output);
Packit 56e0ee
    }
Packit 56e0ee
    return (state = 1) ? 0 : 1;
Packit 56e0ee
}