| 1 | /*
|
|---|
| 2 | * Unix SMB/CIFS implementation.
|
|---|
| 3 | * NetApi testsuite
|
|---|
| 4 | * Copyright (C) Guenther Deschner 2008
|
|---|
| 5 | *
|
|---|
| 6 | * This program is free software; you can redistribute it and/or modify
|
|---|
| 7 | * it under the terms of the GNU General Public License as published by
|
|---|
| 8 | * the Free Software Foundation; either version 3 of the License, or
|
|---|
| 9 | * (at your option) any later version.
|
|---|
| 10 | *
|
|---|
| 11 | * This program is distributed in the hope that it will be useful,
|
|---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 14 | * GNU General Public License for more details.
|
|---|
| 15 | *
|
|---|
| 16 | * You should have received a copy of the GNU General Public License
|
|---|
| 17 | * along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|---|
| 18 | */
|
|---|
| 19 |
|
|---|
| 20 | #include <sys/types.h>
|
|---|
| 21 | #include <inttypes.h>
|
|---|
| 22 | #include <stdio.h>
|
|---|
| 23 | #include <stdlib.h>
|
|---|
| 24 | #include <string.h>
|
|---|
| 25 |
|
|---|
| 26 | #include <netapi.h>
|
|---|
| 27 |
|
|---|
| 28 | #include "common.h"
|
|---|
| 29 |
|
|---|
| 30 | int main(int argc, const char **argv)
|
|---|
| 31 | {
|
|---|
| 32 | NET_API_STATUS status = 0;
|
|---|
| 33 | struct libnetapi_ctx *ctx = NULL;
|
|---|
| 34 | const char *hostname = NULL;
|
|---|
| 35 |
|
|---|
| 36 | poptContext pc;
|
|---|
| 37 | int opt;
|
|---|
| 38 |
|
|---|
| 39 | struct poptOption long_options[] = {
|
|---|
| 40 | POPT_AUTOHELP
|
|---|
| 41 | POPT_COMMON_LIBNETAPI_EXAMPLES
|
|---|
| 42 | POPT_TABLEEND
|
|---|
| 43 | };
|
|---|
| 44 |
|
|---|
| 45 | status = libnetapi_init(&ctx);
|
|---|
| 46 | if (status != 0) {
|
|---|
| 47 | return status;
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| 50 | pc = poptGetContext("netapitest", argc, argv, long_options, 0);
|
|---|
| 51 |
|
|---|
| 52 | poptSetOtherOptionHelp(pc, "hostname");
|
|---|
| 53 | while((opt = poptGetNextOpt(pc)) != -1) {
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | if (!poptPeekArg(pc)) {
|
|---|
| 57 | poptPrintHelp(pc, stderr, 0);
|
|---|
| 58 | goto out;
|
|---|
| 59 | }
|
|---|
| 60 | hostname = poptGetArg(pc);
|
|---|
| 61 |
|
|---|
| 62 | status = netapitest_localgroup(ctx, hostname);
|
|---|
| 63 | if (status) {
|
|---|
| 64 | goto out;
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | status = netapitest_user(ctx, hostname);
|
|---|
| 68 | if (status) {
|
|---|
| 69 | goto out;
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | status = netapitest_group(ctx, hostname);
|
|---|
| 73 | if (status) {
|
|---|
| 74 | goto out;
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | status = netapitest_display(ctx, hostname);
|
|---|
| 78 | if (status) {
|
|---|
| 79 | goto out;
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | status = netapitest_share(ctx, hostname);
|
|---|
| 83 | if (status) {
|
|---|
| 84 | goto out;
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | status = netapitest_file(ctx, hostname);
|
|---|
| 88 | if (status) {
|
|---|
| 89 | goto out;
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | status = netapitest_server(ctx, hostname);
|
|---|
| 93 | if (status) {
|
|---|
| 94 | goto out;
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 | out:
|
|---|
| 98 | if (status != 0) {
|
|---|
| 99 | printf("testsuite failed with: %s\n",
|
|---|
| 100 | libnetapi_get_error_string(ctx, status));
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | libnetapi_free(ctx);
|
|---|
| 104 | poptFreeContext(pc);
|
|---|
| 105 |
|
|---|
| 106 | return status;
|
|---|
| 107 | }
|
|---|