summaryrefslogtreecommitdiffstats
path: root/qemu/roms/SLOF/clients/net-snk/app/netapps/args.c
diff options
context:
space:
mode:
authorRajithaY <rajithax.yerrumsetty@intel.com>2017-04-25 03:31:15 -0700
committerRajitha Yerrumchetty <rajithax.yerrumsetty@intel.com>2017-05-22 06:48:08 +0000
commitbb756eebdac6fd24e8919e2c43f7d2c8c4091f59 (patch)
treeca11e03542edf2d8f631efeca5e1626d211107e3 /qemu/roms/SLOF/clients/net-snk/app/netapps/args.c
parenta14b48d18a9ed03ec191cf16b162206998a895ce (diff)
Adding qemu as a submodule of KVMFORNFV
This Patch includes the changes to add qemu as a submodule to kvmfornfv repo and make use of the updated latest qemu for the execution of all testcase Change-Id: I1280af507a857675c7f81d30c95255635667bdd7 Signed-off-by:RajithaY<rajithax.yerrumsetty@intel.com>
Diffstat (limited to 'qemu/roms/SLOF/clients/net-snk/app/netapps/args.c')
-rw-r--r--qemu/roms/SLOF/clients/net-snk/app/netapps/args.c143
1 files changed, 0 insertions, 143 deletions
diff --git a/qemu/roms/SLOF/clients/net-snk/app/netapps/args.c b/qemu/roms/SLOF/clients/net-snk/app/netapps/args.c
deleted file mode 100644
index 52215e6a7..000000000
--- a/qemu/roms/SLOF/clients/net-snk/app/netapps/args.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation
- * All rights reserved.
- * This program and the accompanying materials
- * are made available under the terms of the BSD License
- * which accompanies this distribution, and is available at
- * http://www.opensource.org/licenses/bsd-license.php
- *
- * Contributors:
- * IBM Corporation - initial implementation
- *****************************************************************************/
-
-#include <stdint.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-#include "args.h"
-
-/**
- * Returns pointer of the n'th argument within a string.
- *
- * @param arg_str string with arguments, separated with ','
- * @param index index of the requested arguments within arg_str
- * @return pointer of argument[index] on success
- * NULL if index is out of range
- */
-const char *
-get_arg_ptr(const char *arg_str, unsigned int index)
-{
- unsigned int i;
-
- for (i = 0; i < index; ++i) {
- for (; *arg_str != ',' && *arg_str != 0; ++arg_str);
- if (*arg_str == 0)
- return 0;
- ++arg_str;
- }
- return arg_str;
-}
-
-/**
- * Returns number of arguments within a string.
- *
- * @param arg_str string with arguments, separated with ','
- * @return number of arguments
- */
-unsigned int
-get_args_count(const char *arg_str)
-{
- unsigned int count = 1;
-
- while ((arg_str = get_arg_ptr(arg_str, 1)) != 0)
- ++count;
- return count;
-}
-
-/**
- * Returns the length of the first argument.
- *
- * @param arg_str string with arguments, separated with ','
- * @return length of first argument
- */
-unsigned int
-get_arg_length(const char *arg_str)
-{
- unsigned int i;
-
- for (i = 0; *arg_str != ',' && *arg_str != 0; ++i)
- ++arg_str;
- return i;
-}
-
-/**
- * Copy the n'th argument within a string into a buffer in respect
- * to a limited buffer size
- *
- * @param arg_str string with arguments, separated with ','
- * @param index index of the requested arguments within arg_str
- * @param buffer pointer to the buffer
- * @param length size of the buffer
- * @return pointer of buffer on success
- * NULL if index is out of range.
- */
-char *
-argncpy(const char *arg_str, unsigned int index, char *buffer,
- unsigned int length)
-{
- const char *ptr = get_arg_ptr(arg_str, index);
- unsigned int len;
-
- if (!ptr)
- return 0;
- len = get_arg_length(ptr);
- if (!strncpy(buffer, ptr, length))
- return 0;
- buffer[len] = 0;
- return buffer;
-}
-
-/**
- * Converts "255.255.255.255" -> char[4] = { 0xff, 0xff, 0xff, 0xff }
- *
- * @param str string to be converted
- * @param ip in case of SUCCESS - 32-bit long IP
- in case of FAULT - zero
- * @return TRUE - IP converted successfully;
- * FALSE - error condition occurs (e.g. bad format)
- */
-int
-strtoip(const char *str, char ip[4])
-{
- char octet[10];
- int res;
- unsigned int i = 0, len;
-
- while (*str != 0) {
- if (i > 3 || !isdigit(*str))
- return 0;
- if (strstr(str, ".") != NULL) {
- len = (int16_t) (strstr(str, ".") - str);
- if (len >= 10)
- return 0;
- strncpy(octet, str, len);
- octet[len] = 0;
- str += len;
- } else {
- strncpy(octet, str, 9);
- octet[9] = 0;
- str += strlen(octet);
- }
- res = strtol(octet, NULL, 10);
- if ((res > 255) || (res < 0))
- return 0;
- ip[i] = (char) res;
- i++;
- if (*str == '.')
- str++;
- }
-
- if (i != 4)
- return 0;
- return -1;
-}