您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ strip函数代码示例

51自学网 2021-06-03 08:30:56
  C++
这篇教程C++ strip函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中strip函数的典型用法代码示例。如果您正苦于以下问题:C++ strip函数的具体用法?C++ strip怎么用?C++ strip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了strip函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: conf_choice

static int conf_choice(struct menu *menu){	struct symbol *sym, *def_sym;	struct menu *child;	int type;	bool is_new;	sym = menu->sym;	type = sym_get_type(sym);	is_new = !sym_has_value(sym);	if (sym_is_changable(sym)) {		conf_sym(menu);		sym_calc_value(sym);		switch (sym_get_tristate_value(sym)) {		case no:			return 1;		case mod:			return 0;		case yes:			break;		}	} else {		switch (sym_get_tristate_value(sym)) {		case no:			return 1;		case mod:			printf("%*s%s/n", indent - 1, "", menu_get_prompt(menu));			return 0;		case yes:			break;		}	}	while (1) {		int cnt, def;		printf("%*s%s/n", indent - 1, "", menu_get_prompt(menu));		def_sym = sym_get_choice_value(sym);		cnt = def = 0;		line[0] = '0';		line[1] = 0;		for (child = menu->list; child; child = child->next) {			if (!menu_is_visible(child))				continue;			if (!child->sym) {				printf("%*c %s/n", indent, '*', menu_get_prompt(child));				continue;			}			cnt++;			if (child->sym == def_sym) {				def = cnt;				printf("%*c", indent, '>');			} else				printf("%*c", indent, ' ');			printf(" %d. %s", cnt, menu_get_prompt(child));			if (child->sym->name)				printf(" (%s)", child->sym->name);			if (!sym_has_value(child->sym))				printf(" (NEW)");			printf("/n");		}		printf("%*schoice", indent - 1, "");		if (cnt == 1) {			printf("[1]: 1/n");			goto conf_childs;		}		printf("[1-%d", cnt);		if (sym->help)			printf("?");		printf("]: ");		switch (input_mode) {		case ask_new:		case ask_silent:			if (!is_new) {				cnt = def;				printf("%d/n", cnt);				break;			}			check_stdin();		case ask_all:			fflush(stdout);			fgets(line, 128, stdin);			strip(line);			if (line[0] == '?') {				printf("/n%s/n", menu->sym->help ?					menu->sym->help : nohelp_text);				continue;			}			if (!line[0])				cnt = def;			else if (isdigit(line[0]))				cnt = atoi(line);			else				continue;			break;		case set_random:			def = (random() % cnt) + 1;		case set_default:		case set_yes:		case set_mod://.........这里部分代码省略.........
开发者ID:FelipeFernandes1988,项目名称:Alice-1121-Modem,代码行数:101,


示例2: main

int main(int argc, char *argv[]){    int indent = 0;    size_t flags = 0;    json_t *json;    json_error_t error;    FILE* file = stdin;    if(argc > 2) {        fprintf(stderr, "usage: %s/n", argv[0]);        return 2;    }    if(argc == 2) {       file = fopen(argv[1], "r");    }    if( !file ) {        perror("invalid file");        return 2;    }    indent = getenv_int("JSON_INDENT");    if(indent < 0 || indent > 255) {        fprintf(stderr, "invalid value for JSON_INDENT: %d/n", indent);        return 2;    }    if(indent > 0)        flags |= JSON_INDENT(indent);    if(getenv_int("JSON_COMPACT") > 0)        flags |= JSON_COMPACT;    if(getenv_int("JSON_ENSURE_ASCII"))        flags |= JSON_ENSURE_ASCII;    if(getenv_int("JSON_PRESERVE_ORDER"))        flags |= JSON_PRESERVE_ORDER;    if(getenv_int("JSON_SORT_KEYS"))        flags |= JSON_SORT_KEYS;    if(getenv_int("JSON_ASSUME_OBJECT"))        flags |= JSON_ASSUME_OBJECT;    if(getenv_int("JSON_ALLOW_EQUAL_SIGN"))        flags |= JSON_ALLOW_EQUAL_SIGN;    if(getenv_int("JSON_QUOTELESS_KEYS"))        flags |= JSON_QUOTELESS_KEYS;    if(getenv_int("STRIP")) {        /* Load to memory, strip leading and trailing whitespace */        size_t size = 0, used = 0;        char *buffer = NULL;        while(1) {            int count;            size = (size == 0 ? 128 : size * 2);            buffer = realloc(buffer, size);            if(!buffer) {                fprintf(stderr, "Unable to allocate %d bytes/n", (int)size);                return 1;            }            count = fread(buffer + used, 1, size - used, stdin);            if(count < size - used) {                buffer[used + count] = '/0';                break;            }            used += count;        }        json = json_loads(strip(buffer), flags, &error);        free(buffer);    }    else        json = json_loadf(file, flags, &error);    if(!json) {        fprintf(stderr, "%d %d %d/n%s/n",                error.line, error.column, error.position,                error.text);        return 1;    }    json_dumpf(json, stdout, flags);    json_decref(json);    return 0;}
开发者ID:tritao,项目名称:jansson,代码行数:94,


示例3: fdopen

/* * Connection handling. Implements 'get' and 'set'. */void *handle_conn(void *void_param) {//int conn, struct hsearch_data *htab) {    thdata *param = (thdata *)void_param;    int conn = param->conn;    struct hsearch_data *htab = param->htab;    char *cmd, *key, *val, *msg, *line;    int len, curr_len, space;    ENTRY entry, *result;    FILE *f = fdopen(conn, "rw");    line = malloc(128);    while (1) {        memset(line, 0, 128);        fgets(line, 128, f);        if (strlen(line) == 0) {        // Client has closed connection            fclose(f);            close(conn);            free(line);            break;        }        cmd = strtok(line, " ");        if (strcmp(cmd, "get") == 0) {            key = strtok(NULL, " ");            strip(key);            entry.key = key;            hsearch_r(entry, FIND, &result, htab);            if (result != NULL) {                val = (char *) result->data;                msg = malloc(strlen(key) + strlen(val) + 20);                sprintf(msg, "VALUE %s 0 %d/r/n%s/r/nEND/r/n",                        key, strlen(val), val);                send(conn, msg, strlen(msg), 0);                free(msg);            } else {                send(conn, "END/r/n", 5, 0);            }        } else if (strcmp(cmd, "set") == 0) {            key = strtok(NULL, " ");            strtok(NULL, " ");  // skip exp            strtok(NULL, " ");  // skip flags            // Length of string to read            len = atoi(strtok(NULL, " ")) + 2;  // + 2 for /r/n            // How much space to allocate. + 1 for /0            space = len + 1;            val = calloc(1, space);            curr_len = 0;            do {                fgets(val + curr_len, space - curr_len, f);                curr_len = strlen(val);            } while (curr_len < len);            strip(val);            entry.key = strdup(key);            entry.data = strdup(val);            hsearch_r(entry, ENTER, &result, htab);            send(conn, "STORED/r/n", 8, 0);            free(val);        }    }    return NULL;}
开发者ID:fy0,项目名称:Key-Value-Polyglot,代码行数:87,


示例4: _nl_find_locale

internal_function_nl_find_locale (const char *locale_path, size_t locale_path_len,		 int category, const char **name){  int mask;  /* Name of the locale for this category.  */  char *loc_name;  const char *language;  const char *modifier;  const char *territory;  const char *codeset;  const char *normalized_codeset;  struct loaded_l10nfile *locale_file;  if ((*name)[0] == '/0')    {      /* The user decides which locale to use by setting environment	 variables.  */      *name = getenv ("LC_ALL");      if (*name == NULL || (*name)[0] == '/0')	*name = getenv (_nl_category_names.str			+ _nl_category_name_idxs[category]);      if (*name == NULL || (*name)[0] == '/0')	*name = getenv ("LANG");    }  if (*name == NULL || (*name)[0] == '/0'      || (__builtin_expect (__libc_enable_secure, 0)	  && strchr (*name, '/') != NULL))    *name = (char *) _nl_C_name;  if (__builtin_expect (strcmp (*name, _nl_C_name), 1) == 0      || __builtin_expect (strcmp (*name, _nl_POSIX_name), 1) == 0)    {      /* We need not load anything.  The needed data is contained in	 the library itself.  */      *name = (char *) _nl_C_name;      return _nl_C[category];    }  /* We really have to load some data.  First we try the archive,     but only if there was no LOCPATH environment variable specified.  */  if (__builtin_expect (locale_path == NULL, 1))    {      struct __locale_data *data	= _nl_load_locale_from_archive (category, name);      if (__builtin_expect (data != NULL, 1))	return data;      /* Nothing in the archive.  Set the default path to search below.  */      locale_path = _nl_default_locale_path;      locale_path_len = sizeof _nl_default_locale_path;    }  /* We really have to load some data.  First see whether the name is     an alias.  Please note that this makes it impossible to have "C"     or "POSIX" as aliases.  */  loc_name = (char *) _nl_expand_alias (*name);  if (loc_name == NULL)    /* It is no alias.  */    loc_name = (char *) *name;  /* Make a writable copy of the locale name.  */  loc_name = strdupa (loc_name);  /* LOCALE can consist of up to four recognized parts for the XPG syntax:		language[_territory[.codeset]][@modifier]     Beside the first all of them are allowed to be missing.  If the     full specified locale is not found, the less specific one are     looked for.  The various part will be stripped off according to     the following order:		(1) codeset		(2) normalized codeset		(3) territory		(4) modifier   */  mask = _nl_explode_name (loc_name, &language, &modifier, &territory,			   &codeset, &normalized_codeset);  if (mask == -1)    /* Memory allocate problem.  */    return NULL;  /* If exactly this locale was already asked for we have an entry with     the complete name.  */  locale_file = _nl_make_l10nflist (&_nl_locale_file_list[category],				    locale_path, locale_path_len, mask,				    language, territory, codeset,				    normalized_codeset, modifier,				    _nl_category_names.str				    + _nl_category_name_idxs[category], 0);  if (locale_file == NULL)    {      /* Find status record for addressed locale file.  We have to search	 through all directories in the locale path.  */      locale_file = _nl_make_l10nflist (&_nl_locale_file_list[category],					locale_path, locale_path_len, mask,					language, territory, codeset,//.........这里部分代码省略.........
开发者ID:dreal,项目名称:tai,代码行数:101,


示例5: xsddefault_read_status_data

/* read all program, host, and service status information */int xsddefault_read_status_data(char *config_file, int options) {#ifdef NO_MMAP	char input[MAX_PLUGIN_OUTPUT_LENGTH] = "";	FILE *fp = NULL;#else	char *input = NULL;	mmapfile *thefile = NULL;#endif	int data_type = XSDDEFAULT_NO_DATA;	hoststatus *temp_hoststatus = NULL;	servicestatus *temp_servicestatus = NULL;	char *var = NULL;	char *val = NULL;	char *ptr = NULL;	int result = 0;	/* comment and downtime vars */	unsigned long comment_id = 0;	int persistent = FALSE;	int expires = FALSE;	time_t expire_time = 0L;	int entry_type = USER_COMMENT;	int source = COMMENTSOURCE_INTERNAL;	time_t entry_time = 0L;	char *host_name = NULL;	char *service_description = NULL;	char *author = NULL;	char *comment_data = NULL;	unsigned long downtime_id = 0;	time_t start_time = 0L;	time_t flex_downtime_start = 0L;	time_t end_time = 0L;	int fixed = FALSE;	unsigned long triggered_by = 0;	unsigned long duration = 0L;	int x = 0;	int is_in_effect = FALSE;	/* initialize some vars */	for(x = 0; x < MAX_CHECK_STATS_TYPES; x++) {		program_stats[x][0] = 0;		program_stats[x][1] = 0;		program_stats[x][2] = 0;		}	/* grab configuration data */	result = xsddefault_grab_config_info(config_file);	if(result == ERROR)		return ERROR;	/* open the status file for reading */#ifdef NO_MMAP	if((fp = fopen(xsddefault_status_log, "r")) == NULL)		return ERROR;#else	if((thefile = mmap_fopen(xsddefault_status_log)) == NULL)		return ERROR;#endif	/* Big speedup when reading status.dat in bulk */	defer_downtime_sorting = 1;	defer_comment_sorting = 1;	/* read all lines in the status file */	while(1) {#ifdef NO_MMAP		strcpy(input, "");		if(fgets(input, sizeof(input), fp) == NULL)			break;#else		/* free memory */		my_free(input);		/* read the next line */		if((input = mmap_fgets(thefile)) == NULL)			break;#endif		strip(input);		/* skip blank lines and comments */		if(input[0] == '#' || input[0] == '/x0')			continue;		else if(!strcmp(input, "info {"))			data_type = XSDDEFAULT_INFO_DATA;		else if(!strcmp(input, "programstatus {"))			data_type = XSDDEFAULT_PROGRAMSTATUS_DATA;		else if(!strcmp(input, "hoststatus {")) {			data_type = XSDDEFAULT_HOSTSTATUS_DATA;			temp_hoststatus = (hoststatus *)calloc(1, sizeof(hoststatus));			}		else if(!strcmp(input, "servicestatus {")) {			data_type = XSDDEFAULT_SERVICESTATUS_DATA;			temp_servicestatus = (servicestatus *)calloc(1, sizeof(servicestatus));			}		else if(!strcmp(input, "contactstatus {")) {			data_type = XSDDEFAULT_CONTACTSTATUS_DATA;//.........这里部分代码省略.........
开发者ID:alexanderhsiang,项目名称:nagios,代码行数:101,


示例6: get_log_entries

//.........这里部分代码省略.........		/* try to open log file */		if (read_gzip_logs == TRUE && strstr(files[i].file_name, ".log.gz")) {#ifdef HAVE_ZLIB_H			if ((gzfile = gzopen(files[i].file_name, "r")) == NULL)#endif				continue;		} else {			if ((thefile = mmap_fopen(files[i].file_name)) == NULL)				continue;		}		while (1) {			/* free memory */			my_free(input);			if (read_gzip_logs == TRUE && strstr(files[i].file_name, ".log.gz")) {#ifdef HAVE_ZLIB_H				if ((gzgets(gzfile, gz_buffer, MAX_COMMAND_BUFFER * 2 + 1)) == NULL)#endif					break;			} else {				if ((input = mmap_fgets(thefile)) == NULL)					break;			}#ifdef HAVE_ZLIB_H			if (read_gzip_logs == TRUE && strstr(files[i].file_name, ".log.gz")) {				gz_buffer[MAX_COMMAND_BUFFER * 2 - 1] = '/0';				input = strdup(gz_buffer);			}#endif			strip(input);			if ((int)strlen(input) == 0)				continue;			/* get timestamp */			temp_buffer = strtok(input, "]");			if (temp_buffer == NULL)				continue;			timestamp = strtoul(temp_buffer + 1, NULL, 10);			/* skip line if out of range */			if ((ts_end >= 0 && timestamp > ts_end) || (ts_start >= 0 && timestamp < ts_start))				continue;			/* get log entry text */			temp_buffer = strtok(NULL, "/n");			if (temp_buffer == NULL)				continue;			/* if we search for something, check if it entry matches search_string */			if (search_string != NULL) {				if (regexec(&preg, temp_buffer, 0, NULL, 0) == REG_NOMATCH)					continue;			}			/* categorize log entry */			if (strstr(temp_buffer, " starting..."))				type = LOGENTRY_STARTUP;			else if (strstr(temp_buffer, " shutting down..."))
开发者ID:gitRigge,项目名称:icinga-core,代码行数:67,


示例7: setup_requirement_line

static int setup_requirement_line(char *name){    char *val[MAX_OPTIONS];    char *prod = NULL;    unsigned n, count;    char *x;    int invert = 0;    if (!strncmp(name, "reject ", 7)) {        name += 7;        invert = 1;    } else if (!strncmp(name, "require ", 8)) {        name += 8;        invert = 0;    } else if (!strncmp(name, "require-for-product:", 20)) {        // Get the product and point name past it        prod = name + 20;        name = strchr(name, ' ');        if (!name) return -1;        *name = 0;        name += 1;        invert = 0;    }    x = strchr(name, '=');    if (x == 0) return 0;    *x = 0;    val[0] = x + 1;    for(count = 1; count < MAX_OPTIONS; count++) {        x = strchr(val[count - 1],'|');        if (x == 0) break;        *x = 0;        val[count] = x + 1;    }    name = strip(name);    for(n = 0; n < count; n++) val[n] = strip(val[n]);    name = strip(name);    if (name == 0) return -1;    const char* var = name;    // Work around an unfortunate name mismatch.    if (!strcmp(name,"board")) var = "product";    const char** out = reinterpret_cast<const char**>(malloc(sizeof(char*) * count));    if (out == 0) return -1;    for(n = 0; n < count; n++) {        out[n] = strdup(strip(val[n]));        if (out[n] == 0) {            for(size_t i = 0; i < n; ++i) {                free((char*) out[i]);            }            free(out);            return -1;        }    }    fb_queue_require(prod, var, invert, n, out);    return 0;}
开发者ID:JohnTsaiAndroid,项目名称:platform_system_core,代码行数:63,


示例8: main

intmain (int argc, char **argv){  char *command_line = NULL;  char input_buffer[MAX_INPUT_BUFFER];  char *address = NULL; /* comma seperated str with addrs/ptrs (sorted) */  char **addresses = NULL;  int n_addresses = 0;  char *msg = NULL;  char *temp_buffer = NULL;  int non_authoritative = FALSE;  int result = STATE_UNKNOWN;  double elapsed_time;  long microsec;  struct timeval tv;  int multi_address;  int parse_address = FALSE; /* This flag scans for Address: but only after Name: */  output chld_out, chld_err;  size_t i;  setlocale (LC_ALL, "");  bindtextdomain (PACKAGE, LOCALEDIR);  textdomain (PACKAGE);  /* Set signal handling and alarm */  if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) {    usage_va(_("Cannot catch SIGALRM"));  }  /* Parse extra opts if any */  argv=np_extra_opts (&argc, argv, progname);  if (process_arguments (argc, argv) == ERROR) {    usage_va(_("Could not parse arguments"));  }  /* get the command to run */  asprintf (&command_line, "%s %s %s", NSLOOKUP_COMMAND, query_address, dns_server);  alarm (timeout_interval);  gettimeofday (&tv, NULL);  if (verbose)    printf ("%s/n", command_line);  /* run the command */  if((np_runcmd(command_line, &chld_out, &chld_err, 0)) != 0) {    msg = (char *)_("nslookup returned an error status");    result = STATE_WARNING;  }  /* scan stdout */  for(i = 0; i < chld_out.lines; i++) {    if (addresses == NULL)      addresses = malloc(sizeof(*addresses)*10);    else if (!(n_addresses % 10))      addresses = realloc(addresses,sizeof(*addresses) * (n_addresses + 10));    if (verbose)      puts(chld_out.line[i]);    if (strstr (chld_out.line[i], ".in-addr.arpa")) {      if ((temp_buffer = strstr (chld_out.line[i], "name = ")))        addresses[n_addresses++] = strdup (temp_buffer + 7);      else {        msg = (char *)_("Warning plugin error");        result = STATE_WARNING;      }    }    /* the server is responding, we just got the host name... */    if (strstr (chld_out.line[i], "Name:"))      parse_address = TRUE;    else if (parse_address == TRUE && (strstr (chld_out.line[i], "Address:") ||             strstr (chld_out.line[i], "Addresses:"))) {      temp_buffer = index (chld_out.line[i], ':');      temp_buffer++;      /* Strip leading spaces */      for (; *temp_buffer != '/0' && *temp_buffer == ' '; temp_buffer++)        /* NOOP */;      strip(temp_buffer);      if (temp_buffer==NULL || strlen(temp_buffer)==0) {        die (STATE_CRITICAL,             _("DNS CRITICAL - '%s' returned empty host name string/n"),             NSLOOKUP_COMMAND);      }      addresses[n_addresses++] = strdup(temp_buffer);    }    else if (strstr (chld_out.line[i], _("Non-authoritative answer:"))) {      non_authoritative = TRUE;    }    result = error_scan (chld_out.line[i]);    if (result != STATE_OK) {      msg = strchr (chld_out.line[i], ':');      if(msg) msg++;//.........这里部分代码省略.........
开发者ID:andersk,项目名称:nagios-plugins,代码行数:101,


示例9: display_notifications

void display_notifications(void) {    mmapfile *thefile=NULL;    char *input=NULL;    char *temp_buffer;    char date_time[MAX_DATETIME_LENGTH];    char alert_level[MAX_INPUT_BUFFER];    char alert_level_class[MAX_INPUT_BUFFER];    char contact_name[MAX_INPUT_BUFFER];    char service_name[MAX_INPUT_BUFFER];    char host_name[MAX_INPUT_BUFFER];    char method_name[MAX_INPUT_BUFFER];    int show_entry;    int total_notifications;    int notification_type=SERVICE_NOTIFICATION;    int notification_detail_type=NOTIFICATION_SERVICE_CRITICAL;    int odd=0;    time_t t;    host *temp_host;    service *temp_service;    int result;    if(use_lifo==TRUE) {        result=read_file_into_lifo(log_file_to_use);        if(result!=LIFO_OK) {            if(result==LIFO_ERROR_MEMORY) {                printf("<P><DIV CLASS='warningMessage'>Not enough memory to reverse log file - displaying notifications in natural order...</DIV></P>");            }            else if(result==LIFO_ERROR_FILE) {                printf("<P><DIV CLASS='errorMessage'>Error: Cannot open log file '%s' for reading!</DIV></P>",log_file_to_use);                return;            }            use_lifo=FALSE;        }    }    if(use_lifo==FALSE) {        if((thefile=mmap_fopen(log_file_to_use))==NULL) {            printf("<P><DIV CLASS='errorMessage'>Error: Cannot open log file '%s' for reading!</DIV></P>",log_file_to_use);            return;        }    }    printf("<p>/n");    printf("<div align='center'>/n");    printf("<table border=0 CLASS='notifications'>/n");    printf("<tr>/n");    printf("<th CLASS='notifications'>Host</th>/n");    printf("<th CLASS='notifications'>Service</th>/n");    printf("<th CLASS='notifications'>Type</th>/n");    printf("<th CLASS='notifications'>Time</th>/n");    printf("<th CLASS='notifications'>Contact</th>/n");    printf("<th CLASS='notifications'>Notification Command</th>/n");    printf("<th CLASS='notifications'>Information</th>/n");    printf("</tr>/n");    total_notifications=0;    while(1) {        free(input);        if(use_lifo==TRUE) {            if((input=pop_lifo())==NULL)                break;        }        else {            if((input=mmap_fgets(thefile))==NULL)                break;        }        strip(input);        /* see if this line contains the notification event string */        if(strstr(input,HOST_NOTIFICATION_STRING)||strstr(input,SERVICE_NOTIFICATION_STRING)) {            if(strstr(input,HOST_NOTIFICATION_STRING))                notification_type=HOST_NOTIFICATION;            else                notification_type=SERVICE_NOTIFICATION;            /* get the date/time */            temp_buffer=(char *)strtok(input,"]");            t=(time_t)(temp_buffer==NULL)?0L:strtoul(temp_buffer+1,NULL,10);            get_time_string(&t,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);            strip(date_time);            /* get the contact name */            temp_buffer=(char *)strtok(NULL,":");            temp_buffer=(char *)strtok(NULL,";");            snprintf(contact_name,sizeof(contact_name),"%s",(temp_buffer==NULL)?"":temp_buffer+1);            contact_name[sizeof(contact_name)-1]='/x0';            /* get the host name */            temp_buffer=(char *)strtok(NULL,";");            snprintf(host_name,sizeof(host_name),"%s",(temp_buffer==NULL)?"":temp_buffer);            host_name[sizeof(host_name)-1]='/x0';            /* get the service name *///.........这里部分代码省略.........
开发者ID:nagios-mirror,项目名称:nagios,代码行数:101,


示例10: throw

   void RinexNavHeader::reallyGetRecord(FFStream& ffs)       throw(std::exception, FFStreamError, StringException)   {      RinexNavStream& strm = dynamic_cast<RinexNavStream&>(ffs);               // if already read, just return      if (strm.headerRead == true)         return;            valid = 0;               // clear out anything that was unsuccessfully read the first      commentList.clear();            while (! (valid & endValid))      {         string line;         strm.formattedGetLine(line);         StringUtils::stripTrailing(line);         if (line.length()==0) continue;         else if (line.length()<60 || line.length()>80)         {            FFStreamError e("Invalid line length");            GPSTK_THROW(e);         }                  string thisLabel(line, 60, 20);                  if (thisLabel == versionString)         {            version = asDouble(line.substr(0,20));            fileType = strip(line.substr(20,20));            if ( (fileType[0] != 'N') &&                 (fileType[0] != 'n'))            {               FFStreamError e("This isn't a Rinex Nav file");               GPSTK_THROW(e);            }            valid |= versionValid;         }         else if (thisLabel == runByString)         {            fileProgram = strip(line.substr(0,20));            fileAgency = strip(line.substr(20,20));            date = strip(line.substr(40,20));            valid |= runByValid;         }         else if (thisLabel == commentString)         {            commentList.push_back(strip(line.substr(0,60)));            valid |= commentValid;         }         else if (thisLabel == ionAlphaString)         {            for(int i = 0; i < 4; i++)               ionAlpha[i] = gpstk::StringUtils::for2doub(line.substr(2 + 12 * i,12));            valid |= ionAlphaValid;         }         else if (thisLabel == ionBetaString)         {            for(int i = 0; i < 4; i++)               ionBeta[i] = gpstk::StringUtils::for2doub(line.substr(2 + 12 * i,12));            valid |= ionBetaValid;         }         else if (thisLabel == deltaUTCString)         {            A0 = gpstk::StringUtils::for2doub(line.substr(3,19));            A1 = gpstk::StringUtils::for2doub(line.substr(22,19));            UTCRefTime = asInt(line.substr(41,9));            UTCRefWeek = asInt(line.substr(50,9));            valid |= deltaUTCValid;         }         else if (thisLabel == leapSecondsString)         {            leapSeconds = asInt(line.substr(0,6));            valid |= leapSecondsValid;         }         else if (thisLabel == endOfHeader)         {            valid |= endValid;         }         else         {            throw(FFStreamError("Unknown header label at line " +                                 asString<size_t>(strm.lineNumber)));         }      }            unsigned long allValid;      if      (version == 2.0)      allValid = allValid20;      else if (version == 2.1)      allValid = allValid21;      else if (version == 2.11)     allValid = allValid211;      else      {         FFStreamError e("Unknown or unsupported RINEX version " +                          asString(version));         GPSTK_THROW(e);      }      //.........这里部分代码省略.........
开发者ID:ianmartin,项目名称:GPSTk,代码行数:101,


示例11: transfer

uint32_t transfer(char **arguments, assembler *instState,table_t *t){ int P_Bit; char *Rd = arguments[0]; char *address = arguments[1]; uint32_t rd = getConst(Rd); int addrlen = strlen(address); if(*address == '='){  //numeric constant;  int val = getConst(address);  if(val <= 0xFF){   //mov instruction;   isMov = 1;   char **inst = malloc(sizeof(char*)*3);   for(int i=0; i<3; i++){	inst[i] = malloc(sizeof(char)*20);   }   strcpy(inst[0],"mov");   strcpy(inst[1],Rd);   strcpy(inst[2],(address+1));   inst[2] = prepend(inst[2],'#');   return ass_data_process(inst,t);  }else{   strip(arguments[1]);   insertExpression(instState->BigVals,arguments[1],val,instState->counter);   rd <<= 12;   uint32_t val_mask = 0xE59F0000;   return val_mask | rd;  } } char **splitAddress = tokeniser(address,","); if(address[0] == '[' && address[4] != ']' && address[3] != ']'){  //PRE instruction;  P_Bit = 1;  char *pre_address = removeBrackets(address);  char **expression = tokeniser(pre_address,".");  uint32_t rn = getConst(expression[0]);  uint32_t transfer_mask1 = 0xE5900000;  uint32_t incVal = getConst(expression[1]);  uint32_t offset = incVal; //TODO: ONCE MOV is fixed replace this with the val generated by mov  rn <<= 16;  rd <<= 12;  return transfer_mask1 | rn | rd | offset; }else if(addrlen <= 5){  //PRE instruction;  P_Bit = 1;  char *Rn = removeBrackets(splitAddress[0]);  uint32_t rn = getConst(Rn);  uint32_t transfer_mask2 = 0xE5900000;  rn <<= 16;  rd <<= 12;  return transfer_mask2 | rn | rd; }else{  //Post instruction;  P_Bit = 0;  uint32_t transfer_mask3 = 0xE6900000;  char **expression = tokeniser(address,".");  uint32_t rn = getConst(removeBrackets(expression[0]));  uint32_t offset = getConst(expression[1]);  rn <<= 16;  rd <<= 12;  return transfer_mask3 | rn | rd | offset; }}
开发者ID:hamzaboukhari,项目名称:ARM,代码行数:70,


示例12: strip

URI::URI(const QString& other):QString()   ,m_Parsed(false),m_HeaderType(SchemeType::NONE){   m_Stripped                     = strip(other,m_HeaderType);   (*static_cast<QString*>(this)) = m_Stripped               ;}
开发者ID:ThereIsNoYeti,项目名称:sflphone,代码行数:6,


示例13: loadConfig

static BOOL loadConfig(char *file, GRABBER **grabbers, int *countGrabbers){	FILE *config;	config = fopen(file,"r");	if(config)	{		char buffer[512], param[256], value[256], *comment;		int e;		e = 0;		while(fgets(buffer,sizeof(buffer),config))		{			uncomment(buffer);			sscanf(buffer,"%[^=]=%[^=]",param,value);			strip(param);			if(!stricmp(param,"grabberid")) e++;		}		*grabbers = (GRABBER *) calloc(e, sizeof(GRABBER));		rewind(config);		e = -1;		while(fgets(buffer,sizeof(buffer),config))		{			uncomment(buffer);			sscanf(buffer,"%[^=]=%[^=]",param,value);			strip(param);			strip(value);			if(!stricmp(param,"grabberid"))			{				e++;				strcpy((*grabbers)[e].id, value);			}			else if(e >=0)			{				if(!stricmp(param,"grabberexe"))					strcpy((*grabbers)[e].exe, value);				else if(!stricmp(param,"grabbertype"))				{					if(!stricmp(value,"win32os2"))						(*grabbers)[e].type = WIN32OS2;					else if(!stricmp(value,"vio"))						(*grabbers)[e].type = VIO;					else if(!stricmp(value,"vdm"))						(*grabbers)[e].type = VDM;				}				else if(!stricmp(param,"grabberin"))					strcpy((*grabbers)[e].input, value);				else if(!stricmp(param,"grabberout"))					strcpy((*grabbers)[e].output, value);				else if(!stricmp(param,"grabbermangling"))					strcpy((*grabbers)[e].mangling, value);				else if(!stricmp(param,"grabberbefore"))					strcpy((*grabbers)[e].before, value);				else if(!stricmp(param,"grabberafter"))					strcpy((*grabbers)[e].after, value);				else if(!stricmp(param,"grabberacceptsoutput"))				{					if(!stricmp(value,"true"))						(*grabbers)[e].acceptsOutput = TRUE;					else						(*grabbers)[e].acceptsOutput = FALSE;				}				else if(!stricmp(param,"grabbernodrive"))				{					if(!stricmp(value,"true"))						(*grabbers)[e].noDrive = TRUE;					else						(*grabbers)[e].noDrive = FALSE;				}			}		}		*countGrabbers = e+1;		fclose(config);		return TRUE;	}	return FALSE;}
开发者ID:OS2World,项目名称:MM-SOUND-CD2MP3PM,代码行数:83,


示例14: conf_choice

static int conf_choice(struct menu *menu){	struct symbol *sym, *def_sym;	struct menu *child;	bool is_new;	sym = menu->sym;	is_new = !sym_has_value(sym);	if (sym_is_changable(sym)) {		conf_sym(menu);		sym_calc_value(sym);		switch (sym_get_tristate_value(sym)) {		case no:			return 1;		case mod:			return 0;		case yes:			break;		}	} else {		switch (sym_get_tristate_value(sym)) {		case no:			return 1;		case mod:			printf("%*s%s/n", indent - 1, "", _(menu_get_prompt(menu)));			return 0;		case yes:			break;		}	}	while (1) {		int cnt, def;		printf("%*s%s/n", indent - 1, "", _(menu_get_prompt(menu)));		def_sym = sym_get_choice_value(sym);		cnt = def = 0;		line[0] = 0;		for (child = menu->list; child; child = child->next) {			if (!menu_is_visible(child))				continue;			if (!child->sym) {				printf("%*c %s/n", indent, '*', _(menu_get_prompt(child)));				continue;			}			cnt++;			if (child->sym == def_sym) {				def = cnt;				printf("%*c", indent, '>');			} else				printf("%*c", indent, ' ');			printf(" %d. %s", cnt, _(menu_get_prompt(child)));			if (child->sym->name)				printf(" (%s)", child->sym->name);			if (!sym_has_value(child->sym))				printf(_(" (NEW)"));			printf("/n");		}		printf(_("%*schoice"), indent - 1, "");		if (cnt == 1) {			printf("[1]: 1/n");			goto conf_childs;		}		printf("[1-%d", cnt);		if (menu_has_help(menu))			printf("?");		printf("]: ");		switch (input_mode) {		case oldconfig:		case silentoldconfig:			if (!is_new) {				cnt = def;				printf("%d/n", cnt);				break;			}			check_stdin();			/* fall through */		case oldaskconfig:			fflush(stdout);			xfgets(line, 128, stdin);			strip(line);			if (line[0] == '?') {				print_help(menu);				continue;			}			if (!line[0])				cnt = def;			else if (isdigit(line[0]))				cnt = atoi(line);			else				continue;			break;		default:			break;		}	conf_childs:		for (child = menu->list; child; child = child->next) {			if (!child->sym || !menu_is_visible(child))				continue;//.........这里部分代码省略.........
开发者ID:96boards,项目名称:wilink8-wlan_backports,代码行数:101,


示例15: setDolp

static voidsetDolp(Char *cp){    Char *dp;    size_t i;    if (dolmod.len == 0 || dolmcnt == 0) {	dolp = cp;	return;    }    cp = Strsave(cp);    for (i = 0; i < dolmod.len; i++) {	int didmod = 0;	/* handle s// [eichin:19910926.0510EST] */	if(dolmod.s[i] == 's') {	    Char delim;	    Char *lhsub, *rhsub, *np;	    size_t lhlen = 0, rhlen = 0;	    delim = dolmod.s[++i];	    if (!delim || letter(delim)		|| Isdigit(delim) || any(" /t/n", delim)) {		seterror(ERR_BADSUBST);		break;	    }	    lhsub = &dolmod.s[++i];	    while(dolmod.s[i] != delim && dolmod.s[++i]) {		lhlen++;	    }	    dolmod.s[i] = 0;	    rhsub = &dolmod.s[++i];	    while(dolmod.s[i] != delim && dolmod.s[++i]) {		rhlen++;	    }	    dolmod.s[i] = 0;	    strip(lhsub);	    strip(rhsub);	    strip(cp);	    dp = cp;	    do {		dp = Strstr(dp, lhsub);		if (dp) {		    ptrdiff_t diff = dp - cp;		    size_t len = (Strlen(cp) + 1 - lhlen + rhlen);		    np = xmalloc(len * sizeof(Char));		    (void) Strncpy(np, cp, diff);		    (void) Strcpy(np + diff, rhsub);		    (void) Strcpy(np + diff + rhlen, dp + lhlen);		    xfree(cp);		    dp = cp = np;		    cp[--len] = '/0';		    didmod = 1;		    if (diff >= (ssize_t)len)			break;		} else {		    /* should this do a seterror? */		    break;		}	    }	    while (dol_flag_a != 0);	    /*	     * restore dolmod for additional words	     */	    dolmod.s[i] = rhsub[-1] = (Char) delim;        } else {	    do {		if ((dp = domod(cp, dolmod.s[i])) != NULL) {		    didmod = 1;		    if (Strcmp(cp, dp) == 0) {			xfree(cp);			cp = dp;			break;		    }		    else {			xfree(cp);			cp = dp;		    }		}		else		    break;	    }	    while (dol_flag_a != 0);	}	if (didmod && dolmcnt != INT_MAX)	    dolmcnt--;#ifdef notdef	else	    break;#endif    }    addla(cp);    dolp = STRNULL;    if (seterr)	stderror(ERR_OLD);//.........这里部分代码省略.........
开发者ID:2trill2spill,项目名称:freebsd,代码行数:101,


示例16: paranthetical_split

std::vector< std::string > paranthetical_split(std::string const &val,        const char separator, std::string const &left,        std::string const &right,int flags){    std::vector< std::string > res;    std::vector<char> part;    bool in_paranthesis = false;    std::string::const_iterator i1 = val.begin();    std::string::const_iterator i2 = val.begin();    std::string lp=left;    std::string rp=right;    if(left.size()!=right.size()) {        ERR_GENERAL << "Left and Right Parenthesis lists not same length/n";        return res;    }    while (i2 != val.end()) {        if(!in_paranthesis && separator && *i2 == separator) {            std::string new_val(i1, i2);            if (flags & STRIP_SPACES)                strip(new_val);            if (!(flags & REMOVE_EMPTY) || !new_val.empty())                res.push_back(new_val);            ++i2;            if (flags & STRIP_SPACES) {                while (i2 != val.end() && *i2 == ' ')                    ++i2;            }            i1=i2;            continue;        }        if(!part.empty() && *i2 == part.back()) {            part.pop_back();            if(!separator && part.empty()) {                std::string new_val(i1, i2);                if (flags & STRIP_SPACES)                    strip(new_val);                res.push_back(new_val);                ++i2;                i1=i2;            } else {                if (part.empty())                    in_paranthesis = false;                ++i2;            }            continue;        }        bool found=false;        for(size_t i=0; i < lp.size(); i++) {            if (*i2 == lp[i]) {                if (!separator && part.empty()) {                    std::string new_val(i1, i2);                    if (flags & STRIP_SPACES)                        strip(new_val);                    res.push_back(new_val);                    ++i2;                    i1=i2;                } else {                    ++i2;                }                part.push_back(rp[i]);                found=true;                break;            }        }        if(!found) {            ++i2;        } else            in_paranthesis = true;    }    std::string new_val(i1, i2);    if (flags & STRIP_SPACES)        strip(new_val);    if (!(flags & REMOVE_EMPTY) || !new_val.empty())        res.push_back(new_val);    if(!part.empty()) {        ERR_GENERAL << "Mismatched paranthesis:/n"<<val<<"/n";;    }    return res;}
开发者ID:slup,项目名称:Battle-for-Wesnoth-on-Android,代码行数:86,


示例17: main

int main(int argc, char * argv[]){  char * filename;  char * basedir;  FILE *fd;  char line[PATH_MAX];  if (argc < 3) {    fprintf(stderr, "Usage: trFilelist synclist_filename basedir/n");    exit(-1);  }  filename = argv[1];  basedir = argv[2];  init_string_list(&file_list, 10);  init_uint_list(&ino_list, 10);  init_string_list(&dir_list, 100);  init_string_list(&softlink_list, 10);  init_string_list(&newdir_list, 100);  get_dir_softlinks(filename, basedir);    if ((fd = fopen(filename, "r")) == NULL) {    fprintf(stderr, "Cannot open file -- %s /n", filename);    return -1;  }  while (1) { /* for each line in the file */    char *pc;    char fn[PATH_MAX];    struct stat st;    int newdir_flag;    if (fgets(line, PATH_MAX, fd)==NULL) break;    strip(line);    if (strlen(line) == 0) continue; /* skip blank line */    if (strcmp(line, ".")==0) continue;    if (strcmp(line, "./")==0) continue;    /* first we look for deleting entry */    if (strncmp(line, "deleting ", 9)==0) {      /* deleting (directory) file_path */      char * p1, *p2, *pf;      p1 = strstr(line, " "); /* the first space */      p2 = strstr(p1+1, " "); /* deleting directory filepath * 20070912 this is old */       pf = (p2) ? p2+1 : p1+1;/* it's always p1+1 */      newdir_flag = has_newdir(pf, &newdir_list);      if ((has_sub_string(pf, &softlink_list)<0) && newdir_flag<0) { 	/* see comments above get_dir_softlinks() */	printf("deleting %s/n", pf);      } else if (newdir_flag>=0) { /* temporary action */	/*** we can simply skip this block later. 20070912 ***/	   	/***/	fprintf(stderr, "CRITICAL ERROR: An old softlink has been changed to a directory!/n");	fprintf(stderr, "                For now, we crash this code for human intervention/n");	fprintf(stderr, "                line= %s/n", line);	exit(-1);	/***/      }      continue;    }        /* the softlink case is indicated by -> */    pc= strstr(line, " -> ");    if (pc) {      *pc = '/0';      output_subs(line);      printf("%s/n", line);      continue;    }    /* if rsync's -H is turned on, the output may contain       file => tar_hardlink_file (relative address)    */    pc= strstr(line, " => ");    if (pc) {      *pc = '/0';      output_subs(line);      printf("%s %s/n", line, pc+4);      continue;    }    /* the rest of the entries should be valid paths */    sprintf(fn, "%s/%s", basedir, line);        if (lstat(fn, &st)<0) continue; /* We skip this bad entry - 				       (1) the header and tail lines				       (2) perhaps the file no longer exists */    /* is this a hardlink? */    if (st.st_nlink > 1) {      int index;      output_subs(line);      if ((index = find_unit((unsigned int)st.st_ino, &ino_list))<0) { 	append_uint_list((unsigned int)st.st_ino, &ino_list);	append_string_list(line, &file_list); /* relative path *///.........这里部分代码省略.........
开发者ID:addisonw,项目名称:mrsync-mac,代码行数:101,


示例18: main

intmain (int argc, char **argv){	short supports_tls=FALSE;	int n = 0;	double elapsed_time;	long microsec;	int result = STATE_UNKNOWN;	char *cmd_str = NULL;	char *helocmd = NULL;	char *error_msg = "";	struct timeval tv;	/* Catch pipe errors in read/write - sometimes occurs when writing QUIT */	(void) signal (SIGPIPE, SIG_IGN);	setlocale (LC_ALL, "");	bindtextdomain (PACKAGE, LOCALEDIR);	textdomain (PACKAGE);	/* Parse extra opts if any */	argv=np_extra_opts (&argc, argv, progname);	if (process_arguments (argc, argv) == ERROR)		usage4 (_("Could not parse arguments"));	/* If localhostname not set on command line, use gethostname to set */	if(! localhostname){		localhostname = malloc (HOST_MAX_BYTES);		if(!localhostname){			printf(_("malloc() failed!/n"));			return STATE_CRITICAL;		}		if(gethostname(localhostname, HOST_MAX_BYTES)){			printf(_("gethostname() failed!/n"));			return STATE_CRITICAL;		}	}	if(use_ehlo)		xasprintf (&helocmd, "%s%s%s", SMTP_EHLO, localhostname, "/r/n");	else		xasprintf (&helocmd, "%s%s%s", SMTP_HELO, localhostname, "/r/n");	if (verbose)		printf("HELOCMD: %s", helocmd);	/* initialize the MAIL command with optional FROM command  */	xasprintf (&cmd_str, "%sFROM:<%s>%s", mail_command, from_arg, "/r/n");	if (verbose && send_mail_from)		printf ("FROM CMD: %s", cmd_str);	/* initialize alarm signal handling */	(void) signal (SIGALRM, socket_timeout_alarm_handler);	/* set socket timeout */	(void) alarm (socket_timeout);	/* start timer */	gettimeofday (&tv, NULL);	/* try to connect to the host at the given port number */	result = my_tcp_connect (server_address, server_port, &sd);	if (result == STATE_OK) { /* we connected */		/* watch for the SMTP connection string and */		/* return a WARNING status if we couldn't read any data */		if (recvlines(buffer, MAX_INPUT_BUFFER) <= 0) {			printf (_("recv() failed/n"));			return STATE_WARNING;		}		else {			if (verbose)				printf ("%s", buffer);			/* strip the buffer of carriage returns */			strip (buffer);			/* make sure we find the response we are looking for */			if (!strstr (buffer, server_expect)) {				if (server_port == SMTP_PORT)					printf (_("Invalid SMTP response received from host: %s/n"), buffer);				else					printf (_("Invalid SMTP response received from host on port %d: %s/n"),									server_port, buffer);				return STATE_WARNING;			}		}		/* send the HELO/EHLO command */		send(sd, helocmd, strlen(helocmd), 0);		/* allow for response to helo command to reach us */		if (recvlines(buffer, MAX_INPUT_BUFFER) <= 0) {			printf (_("recv() failed/n"));			return STATE_WARNING;		} else if(use_ehlo){			if(strstr(buffer, "250 STARTTLS") != NULL ||			   strstr(buffer, "250-STARTTLS") != NULL){				supports_tls=TRUE;			}//.........这里部分代码省略.........
开发者ID:Freeaqingme,项目名称:monitoring-plugins,代码行数:101,


示例19: xpddefault_grab_config_directives

/* processes a single directive */int xpddefault_grab_config_directives(char *input) {    char *temp_ptr = NULL;    char *varname = NULL;    char *varvalue = NULL;    /* get the variable name */    if ((temp_ptr = my_strtok(input, "=")) == NULL)        return ERROR;    if ((varname = (char *)strdup(temp_ptr)) == NULL)        return ERROR;    /* get the variable value */    if ((temp_ptr = my_strtok(NULL, "/n")) == NULL) {        my_free(varname);        return ERROR;    }    if ((varvalue = (char *)strdup(temp_ptr)) == NULL) {        my_free(varname);        return ERROR;    }    if (!strcmp(varname, "perfdata_timeout")) {        strip(varvalue);        xpddefault_perfdata_timeout = atoi(varvalue);    }    else if (!strcmp(varname, "host_perfdata_command"))        xpddefault_host_perfdata_command = (char *)strdup(varvalue);    else if (!strcmp(varname, "service_perfdata_command"))        xpddefault_service_perfdata_command = (char *)strdup(varvalue);    else if (!strcmp(varname, "host_perfdata_file_template"))        xpddefault_host_perfdata_file_template = (char *)strdup(varvalue);    else if (!strcmp(varname, "service_perfdata_file_template"))        xpddefault_service_perfdata_file_template = (char *)strdup(varvalue);    else if (!strcmp(varname, "host_perfdata_file"))        xpddefault_host_perfdata_file = (char *)strdup(varvalue);    else if (!strcmp(varname, "service_perfdata_file"))        xpddefault_service_perfdata_file = (char *)strdup(varvalue);    else if (!strcmp(varname, "host_perfdata_file_mode")) {        xpddefault_host_perfdata_file_pipe = FALSE;        if (strstr(varvalue, "p") != NULL)            xpddefault_host_perfdata_file_pipe = TRUE;        else if (strstr(varvalue, "w") != NULL)            xpddefault_host_perfdata_file_append = FALSE;        else            xpddefault_host_perfdata_file_append = TRUE;    }    else if (!strcmp(varname, "service_perfdata_file_mode")) {        xpddefault_service_perfdata_file_pipe = FALSE;        if (strstr(varvalue, "p") != NULL)            xpddefault_service_perfdata_file_pipe = TRUE;        else if (strstr(varvalue, "w") != NULL)            xpddefault_service_perfdata_file_append = FALSE;        else            xpddefault_service_perfdata_file_append = TRUE;    }    else if (!strcmp(varname, "host_perfdata_file_processing_interval"))        xpddefault_host_perfdata_file_processing_interval = strtoul(varvalue, NULL, 0);    else if (!strcmp(varname, "service_perfdata_file_processing_interval"))        xpddefault_service_perfdata_file_processing_interval = strtoul(varvalue, NULL, 0);    else if (!strcmp(varname, "host_perfdata_file_processing_command"))        xpddefault_host_perfdata_file_processing_command = (char *)strdup(varvalue);    else if (!strcmp(varname, "service_perfdata_file_processing_command"))        xpddefault_service_perfdata_file_processing_command = (char *)strdup(varvalue);    else if (!strcmp(varname, "host_perfdata_process_empty_results"))        xpddefault_host_perfdata_process_empty_results = (atoi(varvalue) > 0) ? TRUE : FALSE;    else if (!strcmp(varname, "service_perfdata_process_empty_results"))        xpddefault_service_perfdata_process_empty_results = (atoi(varvalue) > 0) ? TRUE : FALSE;    /* free memory */    my_free(varname);    my_free(varvalue);    return OK;}
开发者ID:formorer,项目名称:icinga-core,代码行数:91,


示例20: telsnd

static inttelsnd(void){    int tcc;    int count;    int returnValue = 0;    unsigned char *tbp;    tcc = 0;    count = 0;    while (NETROOM() > 2) {	int sc;	int c;	if (tcc == 0) {	    if (count) {		ring_consumed(&ttyiring, count);		returnValue = 1;		count = 0;	    }	    tbp = ttyiring.consume;	    tcc = ring_full_consecutive(&ttyiring);	    if (tcc == 0) {		break;	    }	}	c = *tbp++ & 0xff, sc = strip(c), tcc--; count++;	if (rlogin != _POSIX_VDISABLE) {		if (bol) {			bol = 0;			if (sc == rlogin) {				local = 1;				continue;			}		} else if (local) {			local = 0;			if (sc == '.' || c == termEofChar) {				bol = 1;				command(0, "close/n", 6);				continue;			}			if (sc == termSuspChar) {				bol = 1;				command(0, "z/n", 2);				continue;			}			if (sc == escape) {				command(0, (char *)tbp, tcc);				bol = 1;				count += tcc;				tcc = 0;				flushline = 1;				break;			}			if (sc != rlogin) {				++tcc;				--tbp;				--count;				c = sc = rlogin;			}		}		if ((sc == '/n') || (sc == '/r'))			bol = 1;	} else if (escape != _POSIX_VDISABLE && sc == escape) {	    /*	     * Double escape is a pass through of a single escape character.	     */	    if (tcc && strip(*tbp) == escape) {		tbp++;		tcc--;		count++;		bol = 0;	    } else {		command(0, (char *)tbp, tcc);		bol = 1;		count += tcc;		tcc = 0;		flushline = 1;		break;	    }	} else	    bol = 0;#ifdef	KLUDGELINEMODE	if (kludgelinemode && (globalmode&MODE_EDIT) && (sc == echoc)) {	    if (tcc > 0 && strip(*tbp) == echoc) {		tcc--; tbp++; count++;	    } else {		dontlecho = !dontlecho;		settimer(echotoggle);		setconnmode(0);		flushline = 1;		break;	    }	}#endif	if (sc != _POSIX_VDISABLE && MODE_LOCAL_CHARS(globalmode)) {	    if (TerminalSpecialChars(sc) == 0) {		bol = 1;		break;	    }//.........这里部分代码省略.........
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:101,


示例21: xpddefault_initialize_performance_data

//.........这里部分代码省略.........        temp_command_name = my_strtok(temp_buffer, "!");        if ((temp_command = find_command(temp_command_name)) == NULL) {            logit(NSLOG_RUNTIME_WARNING, TRUE, "Warning: Host performance command '%s' was not found - host performance data will not be processed!/n", temp_command_name);            my_free(xpddefault_host_perfdata_command);        }        my_free(temp_buffer);        /* save the command pointer for later */        xpddefault_host_perfdata_command_ptr = temp_command;    }    if (xpddefault_service_perfdata_command != NULL) {        temp_buffer = (char *)strdup(xpddefault_service_perfdata_command);        /* get the command name, leave any arguments behind */        temp_command_name = my_strtok(temp_buffer, "!");        if ((temp_command = find_command(temp_command_name)) == NULL) {            logit(NSLOG_RUNTIME_WARNING, TRUE, "Warning: Service performance command '%s' was not found - service performance data will not be processed!/n", temp_command_name);            my_free(xpddefault_service_perfdata_command);        }        /* free memory */        my_free(temp_buffer);        /* save the command pointer for later */        xpddefault_service_perfdata_command_ptr = temp_command;    }    if (xpddefault_host_perfdata_file_processing_command != NULL) {        temp_buffer = (char *)strdup(xpddefault_host_perfdata_file_processing_command);        /* get the command name, leave any arguments behind */        temp_command_name = my_strtok(temp_buffer, "!");        if ((temp_command = find_command(temp_command_name)) == NULL) {            logit(NSLOG_RUNTIME_WARNING, TRUE, "Warning: Host performance file processing command '%s' was not found - host performance data file will not be processed!/n", temp_command_name);            my_free(xpddefault_host_perfdata_file_processing_command);        }        /* free memory */        my_free(temp_buffer);        /* save the command pointer for later */        xpddefault_host_perfdata_file_processing_command_ptr = temp_command;    }    if (xpddefault_service_perfdata_file_processing_command != NULL) {        temp_buffer = (char *)strdup(xpddefault_service_perfdata_file_processing_command);        /* get the command name, leave any arguments behind */        temp_command_name = my_strtok(temp_buffer, "!");        if ((temp_command = find_command(temp_command_name)) == NULL) {            logit(NSLOG_RUNTIME_WARNING, TRUE, "Warning: Service performance file processing command '%s' was not found - service performance data file will not be processed!/n", temp_command_name);            my_free(xpddefault_service_perfdata_file_processing_command);        }        /* save the command pointer for later */        xpddefault_service_perfdata_file_processing_command_ptr = temp_command;    }    /* periodically process the host perfdata file */    if (xpddefault_host_perfdata_file_processing_interval > 0 && xpddefault_host_perfdata_file_processing_command != NULL)        schedule_new_event(EVENT_USER_FUNCTION, TRUE, current_time + xpddefault_host_perfdata_file_processing_interval, TRUE, xpddefault_host_perfdata_file_processing_interval, NULL, TRUE, (void *)xpddefault_process_host_perfdata_file, NULL, 0);    /* periodically process the service perfdata file */    if (xpddefault_service_perfdata_file_processing_interval > 0 && xpddefault_service_perfdata_file_processing_command != NULL)        schedule_new_event(EVENT_USER_FUNCTION, TRUE, current_time + xpddefault_service_perfdata_file_processing_interval, TRUE, xpddefault_service_perfdata_file_processing_interval, NULL, TRUE, (void *)xpddefault_process_service_perfdata_file, NULL, 0);    /* save the host perf data file macro */    my_free(mac->x[MACRO_HOSTPERFDATAFILE]);    if (xpddefault_host_perfdata_file != NULL) {        if ((mac->x[MACRO_HOSTPERFDATAFILE] = (char *)strdup(xpddefault_host_perfdata_file)))            strip(mac->x[MACRO_HOSTPERFDATAFILE]);    }    /* save the service perf data file macro */    my_free(mac->x[MACRO_SERVICEPERFDATAFILE]);    if (xpddefault_service_perfdata_file != NULL) {        if ((mac->x[MACRO_SERVICEPERFDATAFILE] = (char *)strdup(xpddefault_service_perfdata_file)))            strip(mac->x[MACRO_SERVICEPERFDATAFILE]);    }    /* free memory */    my_free(temp_buffer);    my_free(buffer);    return OK;}
开发者ID:formorer,项目名称:icinga-core,代码行数:101,


示例22: strtok

bool CVarConsole::parseAssignment(char* input) {	bool isAssignment = false;	for(int x=0; x<strlen(input); x++) {		if(input[x] == '=') {			isAssignment = true;			break;		}	}	if(!isAssignment) return false;	char* token = strtok(input, "=");	bool LHset = false;	char LH[STR_BUFFER];	char RH[STR_BUFFER];	while(token != NULL) {		if(!LHset) {			strcpy(LH, token);			LHset = true;		}		else strcpy(RH, token);		token = strtok(NULL, "=");	}	char* strippedLH = stripVar(strip(LH));	char* strippedRH = strip(RH);	char* varname = stripVar(strippedRH);	char vardata[STR_BUFFER];	if(varname) {		if(!cmap.DoesExist(varname)) {			char buffer[STR_BUFFER];			sprintf(buffer, "Identifier not found /"%s/"/n", varname);			std::string out(buffer);			out_buffer.push_back(out);			return true;		}				if(cmap.GetType(varname) == CType_int) {			CInt tmp(varname);			sprintf(vardata, "%i", *tmp); 		} else if(cmap.GetType(varname) == CType_float) {			CFloat tmp(varname);			sprintf(vardata, "%i", *tmp); 		} if(cmap.GetType(varname) == CType_vec2) {			CVec2 tmp(varname);			sprintf(vardata, "%f, %f", (*tmp)[0], (*tmp)[1]); 		}		strippedRH = vardata;	}	bool vcount = cmap.DoesExist(strippedLH);	if(!vcount) {		char buffer[128];		sprintf(buffer, "Identifier not found /"%s/"/n", strip(LH));		std::string out(buffer);		out_buffer.push_back(out);	} else {		CType type = cmap.GetType(strippedLH);		if(type == CType_int) {			CInt tmp(strippedLH);			*tmp = atoi(strippedRH);		} else if(type == CType_float) {			CFloat tmp(strippedLH);			*tmp = atof(strippedRH);		} else if(type == CType_vec2) {			CVec2 tmp(strippedLH);			char* x = strtok(strippedRH, ",");			char* y = strtok(NULL, ",");			if(!x || !y) {				char buffer[STR_BUFFER];				sprintf(buffer, "Not enough arguments for vec2 assignment", strippedLH);				std::string out(buffer);				out_buffer.push_back(out);				return true;			}			(*tmp)[0] = atof(x);			(*tmp)[1] = atof(y);		}	}	return true;}
开发者ID:AlexanderDzhoganov,项目名称:Game-of-Life,代码行数:83,


示例23: get_one_line

/* Returns a single line of text from the output buffer of the subprocess,   taking into account wrapping, centering, etc.  Returns 0 if no complete   line is currently available. */static char *get_one_line (fliptext_configuration *sc){  char *result = 0;  int wrap_pix = sc->font_wrap_pixels;  int col = 0;  int col_pix = 0;  char *s = sc->buf;  int target = sc->buf_size - sc->buf_tail - 2;  /* Fill as much as we can into sc->buf, but stop at newline.   */  while (target > 0)    {      int c = textclient_getc (sc->tc);      if (c <= 0)        break;      sc->buf[sc->buf_tail++] = (char) c;      sc->buf[sc->buf_tail] = 0;      target--;      if (c == '/r' || c == '/n')        break;    }  while (!result)    {      int cw;      if (s >= sc->buf + sc->buf_tail)        /* Reached end of buffer before end of line.  Bail. */        return 0;      cw = char_width (sc, *s);      if (*s == '/r' || *s == '/n' ||          col_pix + cw >= wrap_pix)        {          int L = s - sc->buf;          if (*s == '/r' || *s == '/n')            {              if (*s == '/r' && s[1] == '/n')  /* swallow CRLF too */                *s++ = 0;              *s++ = 0;            }          else            {              /* We wrapped -- try to back up to the previous word boundary. */              char *s2 = s;              int n = 0;              while (s2 > sc->buf && *s2 != ' ' && *s2 != '/t')                s2--, n++;              if (s2 > sc->buf)                {                  s = s2;                  *s++ = 0;                  L = s - sc->buf;                }            }          if (result) abort();          result = (char *) malloc (L+1);          memcpy (result, sc->buf, L);          result[L] = 0;          {            char *t = result;            char *ut = untabify (t);            strip (ut, (sc->alignment == 0), 1); /* if centering, strip                                                    leading whitespace too */            result = ut;            free (t);          }          if (sc->buf_tail > (s - sc->buf))            {              int i = sc->buf_tail - (s - sc->buf);              memmove (sc->buf, s, i);              sc->buf_tail = i;              sc->buf[sc->buf_tail] = 0;            }          else            {              sc->buf_tail = 0;            }          sc->buf[sc->buf_tail] = 0;          s = sc->buf;          col = 0;          col_pix = 0;        }      else        {          col++;          col_pix += cw;//.........这里部分代码省略.........
开发者ID:MaddTheSane,项目名称:xscreensaver,代码行数:101,


示例24: xsddefault_grab_config_info

/* grab configuration information */int xsddefault_grab_config_info(char *config_file) {	char *input = NULL;	mmapfile *thefile;#ifdef NSCGI	char *input2 = NULL;	mmapfile *thefile2;	char *temp_buffer;#else	nagios_macros *mac;#endif	/*** CORE PASSES IN MAIN CONFIG FILE, CGIS PASS IN CGI CONFIG FILE! ***/	/* open the config file for reading */	if((thefile = mmap_fopen(config_file)) == NULL)		return ERROR;	/* read in all lines from the main config file */	while(1) {		/* free memory */		my_free(input);		/* read the next line */		if((input = mmap_fgets_multiline(thefile)) == NULL)			break;		strip(input);		/* skip blank lines and comments */		if(input[0] == '#' || input[0] == '/x0')			continue;#ifdef NSCGI		/* CGI needs to find and read contents of main config file, since it was passed the name of the CGI config file */		if(strstr(input, "main_config_file") == input) {			temp_buffer = strtok(input, "=");			temp_buffer = strtok(NULL, "/n");			if(temp_buffer == NULL)				continue;			if((thefile2 = mmap_fopen(temp_buffer)) == NULL)				continue;			/* read in all lines from the main config file */			while(1) {				/* free memory */				my_free(input2);				/* read the next line */				if((input2 = mmap_fgets_multiline(thefile2)) == NULL)					break;				strip(input2);				/* skip blank lines and comments */				if(input2[0] == '#' || input2[0] == '/x0')					continue;				xsddefault_grab_config_directives(input2);				}			/* free memory and close the file */			my_free(input2);			mmap_fclose(thefile2);			}#endif#ifdef NSCORE		/* core reads variables directly from the main config file */		xsddefault_grab_config_directives(input);#endif		}	/* free memory and close the file */	my_free(input);	mmap_fclose(thefile);	/* initialize locations if necessary */	if(xsddefault_status_log == NULL)		xsddefault_status_log = (char *)strdup(DEFAULT_STATUS_FILE);	if(xsddefault_temp_file == NULL)		xsddefault_temp_file = (char *)strdup(DEFAULT_TEMP_FILE);	/* make sure we have what we need */	if(xsddefault_status_log == NULL)		return ERROR;	if(xsddefault_temp_file == NULL)		return ERROR;#ifdef NSCORE	mac = get_global_macros();	/* save the status file macro */	my_free(mac->x[MACRO_STATUSDATAFILE]);	if((mac->x[MACRO_STATUSDATAFILE] = (char *)strdup(xsddefault_status_log)))		strip(mac->x[MACRO_STATUSDATAFILE]);//.........这里部分代码省略.........
开发者ID:alexanderhsiang,项目名称:nagios,代码行数:101,


示例25: main

int main(){  /*  encode using public key  */    Big e,m,y,ke,mn,mx;    ifstream public_key("public.key");    ifstream input_file;    ofstream output_file;    static char line[500];    static char buff[256];    static char ifname[13],ofname[13];    BOOL fli,last;    int i,ipt,klen;    miracl *mip=&precision;    mip->IOBASE=60;    public_key >> ke;    mn=root(ke,3);    mx=mn*mn*mn-mn*mn; /* find key length in characters */    klen=bits(mx)/7;    cout << "file to be encoded = " ;    cin.getline(ifname,13);    fli=FALSE;    if (strlen(ifname)>0) fli=TRUE;    if (fli)    { /* set up input file */        strcpy(ofname,ifname);        strip(ofname);        strcat(ofname,".rsa");        input_file.open(ifname,ios::in|ios::nocreate);         if (!input_file)        {            cout << "Unable to open file " << ifname << "/n";            return 0;        }        cout << "encoding message/n";    }    else    { /* accept input from keyboard */        cout << "output filename = ";        cin >> ofname;         strip(ofname);            strcat(ofname,".rsa");        cout << "input message - finish with cntrl z/n";    }    output_file.open(ofname);    ipt=0;    last=FALSE;    while (!last)    { /* encode line by line */        if (fli)        {            input_file.getline(&line[ipt],132);            if (input_file.eof() || input_file.fail()) last=TRUE;        }        else        {            cin.getline(&line[ipt],132);            if (cin.eof() || cin.fail()) last=TRUE;        }        strcat(line,"/n");        ipt=strlen(line);        if (ipt<klen && !last) continue;        while (ipt>=klen)        { /* chop up into klen-sized chunks and encode */            for (i=0;i<klen;i++)                buff[i]=line[i];            buff[klen]='/0';            for (i=klen;i<=ipt;i++)                line[i-klen]=line[i];            ipt-=klen;            mip->IOBASE=128;            m=buff;            e=pow(m,3,ke);            mip->IOBASE=60;            output_file << e << endl;        }        if (last && ipt>0)        { /* now deal with left overs */            mip->IOBASE=128;            m=line;            if (m<mn)            { /* pad out with random number if necessary */                m+=mn*(mn*mn-rand(mn));            }            e=pow(m,3,ke);            mip->IOBASE=60;            output_file << e << endl;        }    }    return 0;}   
开发者ID:flomar,项目名称:CrypTool-VS2015,代码行数:90,


示例26: strip

 void strip(std::string &str){   str = strip(str.c_str(), str.size()); }
开发者ID:TomKlotz,项目名称:OCCA2,代码行数:3,


示例27: conf_sym

static int conf_sym(struct menu *menu){	struct symbol *sym = menu->sym;	tristate oldval, newval;	while (1) {		printf("%*s%s ", indent - 1, "", _(menu->prompt->text));		if (sym->name)			printf("(%s) ", sym->name);		putchar('[');		oldval = sym_get_tristate_value(sym);		switch (oldval) {		case no:			putchar('N');			break;		case mod:			putchar('M');			break;		case yes:			putchar('Y');			break;		}		if (oldval != no && sym_tristate_within_range(sym, no))			printf("/n");		if (oldval != mod && sym_tristate_within_range(sym, mod))			printf("/m");		if (oldval != yes && sym_tristate_within_range(sym, yes))			printf("/y");		if (menu_has_help(menu))			printf("/?");		printf("] ");		if (!conf_askvalue(sym, sym_get_string_value(sym)))			return 0;		strip(line);		switch (line[0]) {		case 'n':		case 'N':			newval = no;			if (!line[1] || !strcmp(&line[1], "o"))				break;			continue;		case 'm':		case 'M':			newval = mod;			if (!line[1])				break;			continue;		case 'y':		case 'Y':			newval = yes;			if (!line[1] || !strcmp(&line[1], "es"))				break;			continue;		case 0:			newval = oldval;			break;		case '?':			goto help;		default:			continue;		}		if (sym_set_tristate_value(sym, newval))			return 0;help:		print_help(menu);	}}
开发者ID:96boards,项目名称:wilink8-wlan_backports,代码行数:68,


示例28: main

int main(int argc, char *argv[]){	/* Win32 stuff */#ifdef _WIN32	WSADATA wsa;#endif	if (argc == 1)		return 0;	char *server = strtok(argv[1], ":"), *aport;	short port;	if ((aport = strtok(NULL, "")))		port = atoi(aport);	else		port = 25;	if (!server)	{		alog("No Server");		/* Bad, bad, bad. This was a return from main with no value! -GD */		return 0;	}	else		alog("SMTP: server %s port %d",server,port);	/* The WSAStartup function initiates use of WS2_32.DLL by a process. */	/* guessing we can skip it under *nix */#ifdef _WIN32	if (WSAStartup(MAKEWORD(1, 1), &wsa))		return 0;#endif	char buf[8192];	bool headers_done = false;	/* Read the message and parse it */	while (fgets(buf, 8192, stdin))	{		if (smtp_is_header(buf) && !headers_done)		{			smail.smtp_headers.push_back(strip(buf) + "/r/n");			std::string header, value;			smtp_parse_header(buf, header, value);			if (header == "From:")			{				alog("SMTP: from: %s", value.c_str());				smail.from = value;			}			else if (header == "To:")			{				alog("SMTP: to: %s", value.c_str());				smtp_set_to(value);			}			else if (smtp_is_end(buf))				break;			else			{				headers_done = true;				smail.smtp_body.push_back(strip(buf) + "/r/n");			}		}		else			smail.smtp_body.push_back(strip(buf) + "/r/n");	}	if (!smtp_connect(server, port))	{		alog("SMTP: failed to connect to %s:%d", server, port);		return 0;	}	if (!smtp_send_email())	{		alog("SMTP: error during sending of mail");		return 0;	}	smtp_disconnect();	return 1;}
开发者ID:xxgrunge,项目名称:anope196,代码行数:79,


示例29: ssh_connect

intssh_connect (char *haddr, int hport, char *remote_version, char *remote_protocol){	int sd;	int result;	char *output = NULL;	char *buffer = NULL;	char *ssh_proto = NULL;	char *ssh_server = NULL;	static char *rev_no = VERSION;	struct timeval tv;	double elapsed_time;	gettimeofday(&tv, NULL);	result = my_tcp_connect (haddr, hport, &sd);	if (result != STATE_OK)		return result;	output = (char *) malloc (BUFF_SZ + 1);	memset (output, 0, BUFF_SZ + 1);	recv (sd, output, BUFF_SZ, 0);	if (strncmp (output, "SSH", 3)) {		printf (_("Server answer: %s"), output);		close(sd);		exit (STATE_CRITICAL);	}	else {		strip (output);		if (verbose)			printf ("%s/n", output);		ssh_proto = output + 4;		ssh_server = ssh_proto + strspn (ssh_proto, "-0123456789. ");		ssh_proto[strspn (ssh_proto, "0123456789. ")] = 0;		xasprintf (&buffer, "SSH-%s-check_ssh_%s/r/n", ssh_proto, rev_no);		send (sd, buffer, strlen (buffer), MSG_DONTWAIT);		if (verbose)			printf ("%s/n", buffer);		if (remote_version && strcmp(remote_version, ssh_server)) {			printf				(_("SSH WARNING - %s (protocol %s) version mismatch, expected '%s'/n"),				 ssh_server, ssh_proto, remote_version);			close(sd);			exit (STATE_WARNING);		}		if (remote_protocol && strcmp(remote_protocol, ssh_proto)) {			printf				(_("SSH WARNING - %s (protocol %s) protocol version mismatch, expected '%s'/n"),				 ssh_server, ssh_proto, remote_protocol);			close(sd);			exit (STATE_WARNING);		}		elapsed_time = (double)deltime(tv) / 1.0e6;		printf			(_("SSH OK - %s (protocol %s) | %s/n"),			 ssh_server, ssh_proto, fperfdata("time", elapsed_time, "s",			 FALSE, 0, FALSE, 0, TRUE, 0, TRUE, (int)socket_timeout));		close(sd);		exit (STATE_OK);	}}
开发者ID:Freeaqingme,项目名称:monitoring-plugins,代码行数:67,



注:本文中的strip函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ stripLeadingAndTrailingHTMLSpaces函数代码示例
C++ stringtab函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。