args.c

来自「MANTIS是由科罗拉多大学开发的传感器网络嵌入式操作系统。 这是mantis」· C语言 代码 · 共 68 行

C
68
字号
//  This file is part of MANTIS OS, Operating System//  See http://mantis.cs.colorado.edu/////  Copyright (C) 2003,2004,2005 University of Colorado, Boulder////  This program is free software; you can redistribute it and/or//  modify it under the terms of the mos license (see file LICENSE)/**************************************************************************//* File:      mos.h                                                       *//* Author     Jeff Rose   :  rosejn@colorado.edu                          *//*   Date:  10/12/03                                                      *//*                                                                        *//* A simple argument parser for using command line args in linux (xmos).  *//**************************************************************************/#include "mos.h"#include <string.h>#include "arg.h"int nargs;char **args;uint8_t arg_init(int argc, char *argv[]){   nargs = argc;   args = argv;   return 0;}int mos_arg_argc (void){  return nargs;}char **mos_arg_argv (void){  return args;}uint8_t mos_arg_check(uint8_t *arg, uint8_t **val){   uint8_t i, found;   found = 0;   for(i = 0; i < nargs; i++)   {      if(strcmp(args[i], arg) == 0)      {	 found = 1;	 break;      }   }   if(found)   {      if((val != NULL) && (i < nargs-1))	 *val = args[i+1];      return 1;   }   else      return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?