📄 getargs.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 + -