⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getargs.c

📁 一个基于linux的TCP/IP协议栈的实现
💻 C
字号:
/* getargs.c * linqianghe@163.com * 2006-11-05 */#include <sys/types.h>#include <sys/socket.h>#include <net/if.h>#include <errno.h>#include <signal.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include "net-support.h"#include "pathnames.h"int getargs(char *string, char *arguments[]){	int len = strlen(string); 	char temp[len+1];	char *sp, *ptr;	int i, argc;	char want;	sp = string;	i = 0;	strcpy(temp, string);	ptr = temp;	while (*ptr != '\0' && i < 31) {		while (*ptr == ' ' || *ptr == '\t')			ptr++;		arguments[i++] = sp;		if( *ptr == '"' || *ptr == '\'' ){			want = *ptr++;			while( *ptr != '\0' ){				if( *ptr == want && *(ptr - 1) != '\\' ){					ptr++;					break;				}				*sp++ = *ptr++;			}		}else{			while( *ptr != '\0' && *ptr != ' ' && *ptr != '\t')				*sp++ = *ptr++;		}		*sp++ = '\0';		if( *ptr != '\0' ){			while( *ptr == ' ' || *ptr == '\t' )				ptr++;		}	}	argc = i;	while( i < 32 )		arguments[i++] = (char *) NULL;	return (argc);}

⌨️ 快捷键说明

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