| 1 | /* $Id: version.c 1183 2007-10-05 22:16:46Z bird $ */
|
|---|
| 2 | /** @file
|
|---|
| 3 | * kbuild_version(), helper function.
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | /*
|
|---|
| 7 | * Copyright (c) 2007 knut st. osmundsen <bird-src-spam@anduin.net>
|
|---|
| 8 | *
|
|---|
| 9 | * This file is part of kBuild.
|
|---|
| 10 | *
|
|---|
| 11 | * kBuild is free software; you can redistribute it and/or modify
|
|---|
| 12 | * it under the terms of the GNU General Public License as published by
|
|---|
| 13 | * the Free Software Foundation; either version 2 of the License, or
|
|---|
| 14 | * (at your option) any later version.
|
|---|
| 15 | *
|
|---|
| 16 | * kBuild is distributed in the hope that it will be useful,
|
|---|
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 19 | * GNU General Public License for more details.
|
|---|
| 20 | *
|
|---|
| 21 | * You should have received a copy of the GNU General Public License
|
|---|
| 22 | * along with kBuild; if not, write to the Free Software
|
|---|
| 23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|---|
| 24 | *
|
|---|
| 25 | */
|
|---|
| 26 |
|
|---|
| 27 | #include "kmkbuiltin.h"
|
|---|
| 28 | #include <string.h>
|
|---|
| 29 | #include <stdio.h>
|
|---|
| 30 |
|
|---|
| 31 | /**
|
|---|
| 32 | * Prints the kBuild version message and returns 0.
|
|---|
| 33 | *
|
|---|
| 34 | * @returns 0
|
|---|
| 35 | * @param argv0 The argv0.
|
|---|
| 36 | */
|
|---|
| 37 | int kbuild_version(const char *argv0)
|
|---|
| 38 | {
|
|---|
| 39 | const char *tmp;
|
|---|
| 40 |
|
|---|
| 41 | /* skip the path */
|
|---|
| 42 | for (tmp = strpbrk(argv0, "\\/:"); tmp; tmp = strpbrk(argv0, "\\/:"))
|
|---|
| 43 | argv0 = tmp + 1;
|
|---|
| 44 |
|
|---|
| 45 | /* find the end, ignoring extenions */
|
|---|
| 46 | tmp = strrchr(argv0, '.');
|
|---|
| 47 | if (!tmp)
|
|---|
| 48 | tmp = strchr(argv0, '\0');
|
|---|
| 49 |
|
|---|
| 50 | printf("%.*s - kBuild version %d.%d.%d\n",
|
|---|
| 51 | tmp - argv0, argv0,
|
|---|
| 52 | KBUILD_VERSION_MAJOR, KBUILD_VERSION_MINOR, KBUILD_VERSION_PATCH);
|
|---|
| 53 | return 0;
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|