当前位置: 首页>>代码示例>>C++>>正文


C++ STRCMP函数代码示例

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


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

示例1: is_unit_present

int is_unit_present(char *label, char *unit){
  if(strlen(label)!=strlen(unit)||STRCMP(label,unit)!=0)return 0;
  return 1;
}
开发者ID:tkorhon1,项目名称:FDS-SMVgit,代码行数:4,代码来源:unit.c

示例2: DoPyCommand

/*
 * External interface
 */
    static void
DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg)
{
#ifndef PY_CAN_RECURSE
    static int		recursive = 0;
#endif
#if defined(MACOS) && !defined(MACOS_X_UNIX)
    GrafPtr		oldPort;
#endif
#if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
    char		*saved_locale;
#endif
#ifdef PY_CAN_RECURSE
    PyGILState_STATE	pygilstate;
#endif

#ifndef PY_CAN_RECURSE
    if (recursive)
    {
	EMSG(_("E659: Cannot invoke Python recursively"));
	return;
    }
    ++recursive;
#endif

#if defined(MACOS) && !defined(MACOS_X_UNIX)
    GetPort(&oldPort);
    /* Check if the Python library is available */
    if ((Ptr)PyMac_Initialize == (Ptr)kUnresolvedCFragSymbolAddress)
	goto theend;
#endif
    if (Python_Init())
	goto theend;

    init_range(arg);

    Python_Release_Vim();	    /* leave vim */

#if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
    /* Python only works properly when the LC_NUMERIC locale is "C". */
    saved_locale = setlocale(LC_NUMERIC, NULL);
    if (saved_locale == NULL || STRCMP(saved_locale, "C") == 0)
	saved_locale = NULL;
    else
    {
	/* Need to make a copy, value may change when setting new locale. */
	saved_locale = (char *) PY_STRSAVE(saved_locale);
	(void)setlocale(LC_NUMERIC, "C");
    }
#endif

#ifdef PY_CAN_RECURSE
    pygilstate = PyGILState_Ensure();
#else
    Python_RestoreThread();	    /* enter python */
#endif

    run((char *) cmd, arg
#ifdef PY_CAN_RECURSE
	    , &pygilstate
#endif
	    );

#ifdef PY_CAN_RECURSE
    PyGILState_Release(pygilstate);
#else
    Python_SaveThread();	    /* leave python */
#endif

#if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
    if (saved_locale != NULL)
    {
	(void)setlocale(LC_NUMERIC, saved_locale);
	PyMem_Free(saved_locale);
    }
#endif

    Python_Lock_Vim();		    /* enter vim */
    PythonIO_Flush();
#if defined(MACOS) && !defined(MACOS_X_UNIX)
    SetPort(oldPort);
#endif

theend:
#ifndef PY_CAN_RECURSE
    --recursive;
#endif
    return;
}
开发者ID:AaronDP,项目名称:vim_adbshell,代码行数:92,代码来源:if_python.c

示例3: parse_routers

/*
 * Routers
 * */
void parse_routers()
{
	xmlXPathObjectPtr xmlobject;
	xmlNode *router;
        char *text, *request="/config_ndpmon/routers";

	xmlobject = xmlXPathEval ((xmlChar*)request, xpctxt);
	if (xmlobject->nodesetval==NULL) {
		xmlXPathFreeObject (xmlobject);
		return;
        }
	router = xmlobject->nodesetval->nodeTab[0]->children;

	while(router != NULL) {
		if (router->type == XML_ELEMENT_NODE && STRCMP(router->name,"router")==0) {
			struct ether_addr mac;
			struct in6_addr lla;
			uint8_t  param_curhoplimit=0;
			uint8_t  param_flags_reserved=0;
			uint16_t param_router_lifetime=0;
			uint32_t param_reachable_timer=0;
			uint32_t param_retrans_timer=0;
			uint32_t param_mtu=0;
			int params_volatile=1;
			prefix_t* tmp_prefix = NULL;
			address_t* tmp_address = NULL;
			xmlNode *param = router->children;
			int vlan_id = 4095;
			while(param != NULL) {
				if (param->type != XML_ELEMENT_NODE) {
					param = param->next;
					continue;
				}
                                /* We have an XML Element: */
				if( !STRCMP(param->name,"mac") ) {
					memcpy(&mac,ether_aton((char *)XML_GET_CONTENT(param->children)),sizeof(struct ether_addr));
				}
				else if( !STRCMP(param->name,"vlan_id") ) {
					text = (char*)XML_GET_CONTENT(param->children);
					vlan_id = atoi(text!=NULL?text:"4095");
				}
				else if( !STRCMP(param->name,"lla") ) {
					inet_pton(AF_INET6,(char *)XML_GET_CONTENT(param->children), &lla);
				}
				else if( !STRCMP(param->name,"param_curhoplimit") ) {
					text = (char*)XML_GET_CONTENT(param->children);
					param_curhoplimit = atoi(text!=NULL?text:"0");
					}
				else if( !STRCMP(param->name,"param_flags_reserved") ) {
					text = (char*)XML_GET_CONTENT(param->children);
					param_flags_reserved = atoi(text!=NULL?text:"0");
					}
				else if( !STRCMP(param->name,"param_router_lifetime") ) {
					text = (char*)XML_GET_CONTENT(param->children);
					param_router_lifetime = atoi(text!=NULL?text:"0");
				}
				else if( !STRCMP(param->name,"param_reachable_timer") ) {
					text = (char*)XML_GET_CONTENT(param->children);
					param_reachable_timer = strtoul(text!=NULL?text:"0", NULL, 10);
				}
				else if( !STRCMP(param->name,"param_retrans_timer") ) {
					text = (char*)XML_GET_CONTENT(param->children);
					param_retrans_timer = strtoul(text!=NULL?text:"0", NULL, 10);
				}
				else if( !STRCMP(param->name,"param_mtu") ) {
					text = (char*)XML_GET_CONTENT(param->children);
					param_mtu = strtoul(text!=NULL?text:"0", NULL, 10);
				}
				else if( !STRCMP(param->name,"params_volatile") ) {
					text = (char*)XML_GET_CONTENT(param->children);
					params_volatile = atoi(text!=NULL?text:"1");
				}
				else if( !STRCMP(param->name,"addresses") ) {
					xmlNode *address = param->children;
					while(address != NULL) {
						if (address->type == XML_ELEMENT_NODE &&  STRCMP(address->name,"address")==0 ) {
							/* Read address: */
							address_t* new_address = malloc(sizeof(address_t));
							if (new_address==NULL) {
								fprintf(stderr, "malloc failed.");
							}
							inet_pton(AF_INET6,(char *)XML_GET_CONTENT(address->children), &new_address->address);
							/* Add address to tmp address list: */
							new_address->next = tmp_address;
							tmp_address = new_address;
						}
						/* Fetch next address node: */
						address = address->next;
					}
				} /* end addresses */
				else if( !STRCMP(param->name,"prefixes") ) {
					xmlNode *prefix = param->children;
					while(prefix != NULL) {
						if (prefix->type == XML_ELEMENT_NODE && STRCMP(prefix->name,"prefix")==0) {
							/* Read prefix params: */
							xmlNode *prefix_param = prefix->children;
							prefix_t* new_prefix = malloc(sizeof(prefix_t));
//.........这里部分代码省略.........
开发者ID:ayourtch,项目名称:ndpmon-dot1q,代码行数:101,代码来源:parser.c

示例4: oph_server_conf_load


//.........这里部分代码省略.........
        }
      }

      //Check if row is a comment
      j = 0;
      while(buffer[j] == ' ') j++;
      //Row is a comment
      if(buffer[j] == OPH_SERVER_CONF_COMMENT) continue;
      //Check if row is newline
      j = 0;
      while(buffer[j] == ' ') j++;
      //Row is a newline
      if(buffer[j] == '\n') continue;

      sscanf (buffer, "[%[^]]", tmp_buffer);

      if(instance_flag == 0){
        //If row does not contain an instance ref then step to next row
        if (!(instance_string = strstr (tmp_buffer, OPH_SERVER_CONF_INSTANCE))){
          continue;
        }
        else{
          //Check instance number
          if(instance != 0){
            instance_string += strlen(OPH_SERVER_CONF_INSTANCE);
            instance_number = (short unsigned int)strtol(instance_string, NULL, 10);
            if(instance_number == 0) continue;
            if(instance_number != instance) continue;
          }

          //If instance header is found read all lines until next one
          instance_flag = 1;
        }
      }  
      else{
        if (!strstr (tmp_buffer, OPH_SERVER_CONF_INSTANCE)){
          //Parse row          

          //Get param-value separator
          value = NULL;
          position = position2 = NULL;  
          position = strchr(buffer, '=');
          if(position != NULL){
            //Set = symbol to NULL
            position[0] = 0;
            position++;
            //If new line char is read, then remove it
            if((position2 = strchr(position, '\n')) != NULL){
              position2[0] = 0;
            }
            
            //Check if param is allowed
            i = 0;
            param_iter = oph_server_conf_params[i++];
            while(param_iter){
              if(STRCMP(buffer, param_iter) == 0) break;
              param_iter = oph_server_conf_params[i++];
            }

            if( param_iter == NULL ) {
              pmesg(LOG_DEBUG, __FILE__, __LINE__, "Configuration param not allowed %s\n", buffer);
              continue;
            }

            //Alloc value to be added to hash table
            value = strndup(position, OPH_SERVER_CONF_LINE_LEN);
            if(value == NULL){
              pmesg(LOG_ERROR, __FILE__, __LINE__, "Error while copying param %s\n", buffer);
              fclose(file);
              hashtbl_destroy(*hashtbl);
              *hashtbl = NULL;
              return OPH_SERVER_CONF_ERROR;
            }

		        if(hashtbl_insert(*hashtbl, buffer, value)){
              pmesg(LOG_ERROR, __FILE__, __LINE__, "Error while loading param %s\n", buffer);
              fclose(file);
              free(value);
              hashtbl_destroy(*hashtbl);
              *hashtbl = NULL;
              return OPH_SERVER_CONF_ERROR;
            }
            pmesg(LOG_DEBUG, __FILE__, __LINE__, "LOADED PARAM: %s = %s \n", buffer, position);
          }
          else{
              pmesg(LOG_DEBUG, __FILE__, __LINE__, "Configuration param corrupted %s\n", buffer);
          }
        }
        else{
          //Found second instance ref, end cycle
          break;   
        }
      }
    }

    fclose(file);
  }

	return OPH_SERVER_CONF_SUCCESS;
}
开发者ID:AAmedeo,项目名称:ophidia-io-server,代码行数:101,代码来源:oph_server_confs.c

示例5: gtmrecv_get_opt


//.........这里部分代码省略.........
			/* Check if plaintext-fallback mode is specified. Default option is NOPLAINTEXTFALLBACK. */
			if (CLI_PRESENT == (plaintext_fallback = cli_present("PLAINTEXTFALLBACK")))
				repl_tls.plaintext_fallback = (plaintext_fallback != CLI_NEGATED);
			else
				repl_tls.plaintext_fallback = FALSE;
		}
#		endif
	}
	if ((gtmrecv_options.start && 0 != gtmrecv_options.listen_port) || gtmrecv_options.statslog || gtmrecv_options.changelog)
	{
		log = (CLI_PRESENT == cli_present("LOG"));
		log_interval_specified = (CLI_PRESENT == cli_present("LOG_INTERVAL"));
		if (log)
		{
			log_file_len = MAX_FN_LEN + 1;
			if (!cli_get_str("LOG", gtmrecv_options.log_file, &log_file_len))
			{
				util_out_print("Error parsing LOG qualifier", TRUE);
				return (-1);
			}
		} else
			gtmrecv_options.log_file[0] = '\0';
		gtmrecv_options.rcvr_log_interval = gtmrecv_options.upd_log_interval = 0;
		if (log_interval_specified
		    && 0 == cli_parse_two_numbers("LOG_INTERVAL", GTMRECV_LOGINTERVAL_DELIM, &gtmrecv_options.rcvr_log_interval,
							&gtmrecv_options.upd_log_interval))
			return (-1);
		if (gtmrecv_options.start)
		{
			if (0 == gtmrecv_options.rcvr_log_interval)
				gtmrecv_options.rcvr_log_interval = LOGTRNUM_INTERVAL;
			if (0 == gtmrecv_options.upd_log_interval)
				gtmrecv_options.upd_log_interval = LOGTRNUM_INTERVAL;
		} /* For changelog, interval == 0 implies don't change log interval already established */
		  /* We ignore interval specification for statslog, Vinaya 2005/02/07 */
	}
	if (gtmrecv_options.shut_down)
	{
		if (CLI_PRESENT == (status = cli_present("TIMEOUT")))
		{
			if (!cli_get_int("TIMEOUT", &gtmrecv_options.shutdown_time))
			{
				util_out_print("Error parsing TIMEOUT qualifier", TRUE);
				return (-1);
			}
			if (DEFAULT_SHUTDOWN_TIMEOUT < gtmrecv_options.shutdown_time || 0 > gtmrecv_options.shutdown_time)
			{
				gtmrecv_options.shutdown_time = DEFAULT_SHUTDOWN_TIMEOUT;
				util_out_print("shutdown TIMEOUT changed to !UL", TRUE, gtmrecv_options.shutdown_time);
			}
		} else if (CLI_NEGATED == status)
			gtmrecv_options.shutdown_time = -1;
		else /* TIMEOUT not specified */
			gtmrecv_options.shutdown_time = DEFAULT_SHUTDOWN_TIMEOUT;
	}
	if (gtmrecv_options.statslog)
	{
		statslog_val_len = 4; /* max(strlen("ON"), strlen("OFF")) + 1 */
		if (!cli_get_str("STATSLOG", statslog_val, &statslog_val_len))
		{
			util_out_print("Error parsing STATSLOG qualifier", TRUE);
			return (-1);
		}
		cli_strupper(statslog_val);
		if (0 == STRCMP(statslog_val, "ON"))
			gtmrecv_options.statslog = TRUE;
		else if (0 == STRCMP(statslog_val, "OFF"))
			gtmrecv_options.statslog = FALSE;
		else
		{
			util_out_print("Invalid value for STATSLOG qualifier, should be either ON or OFF", TRUE);
			return (-1);
		}
	}
	gtmrecv_options.n_readers = gtmrecv_options.n_writers = 0;
	if (gtmrecv_options.helpers && gtmrecv_options.start)
	{ /* parse the helpers qualifier to find out how many readers and writes have to be started */
		if (0 == (status = cli_parse_two_numbers("HELPERS", UPD_HELPERS_DELIM, &n_helpers, &n_readers)))
			return (-1);
		if (!(status & CLI_2NUM_FIRST_SPECIFIED))
			n_helpers = DEFAULT_UPD_HELPERS;
		if (MIN_UPD_HELPERS > n_helpers || MAX_UPD_HELPERS < n_helpers)
		{
			util_out_print("Invalid number of helpers; must be in the range [!UL,!UL]", TRUE, MIN_UPD_HELPERS,
					MAX_UPD_HELPERS);
			return (-1);
		}
		if (!(status & CLI_2NUM_SECOND_SPECIFIED))
			n_readers = (int)(n_helpers * ((float)DEFAULT_UPD_HELP_READERS)/DEFAULT_UPD_HELPERS); /* may round down */
		if (n_readers > n_helpers)
		{
			n_readers = n_helpers;
			util_out_print("Number of readers exceeds number of helpers, reducing number of readers to number of "
					"helpers", TRUE);
		}
		gtmrecv_options.n_readers = n_readers;
		gtmrecv_options.n_writers = n_helpers - n_readers;
	}
	return (0);
}
开发者ID:mihawk,项目名称:fis-gtm,代码行数:101,代码来源:gtmrecv_get_opt.c

示例6: FUSEFSAL_load_FS_specific_parameter_from_conf

fsal_status_t FUSEFSAL_load_FS_specific_parameter_from_conf(config_file_t in_config,
                                                            fsal_parameter_t *
                                                            out_parameter)
{
  int err;
  int var_max, var_index;
  char *key_name;
  char *key_value;
  config_item_t block;

  block = config_FindItemByName(in_config, CONF_LABEL_FS_SPECIFIC);

  /* cannot read item */
  if(block == NULL)
    {
      LogCrit(COMPONENT_CONFIG, "FSAL LOAD PARAMETER: Cannot read item \"%s\" from configuration file",
              CONF_LABEL_FS_SPECIFIC);
      ReturnCode(ERR_FSAL_NOENT, 0);
    }
  else if(config_ItemType(block) != CONFIG_ITEM_BLOCK)
    {
      LogCrit(COMPONENT_CONFIG, "FSAL LOAD PARAMETER: Item \"%s\" is expected to be a block",
              CONF_LABEL_FS_SPECIFIC);
      ReturnCode(ERR_FSAL_INVAL, 0);
    }

  /* makes an iteration on the (key, value) couplets */

  var_max = config_GetNbItems(block);

  for(var_index = 0; var_index < var_max; var_index++)
    {
      config_item_t item;

      item = config_GetItemByIndex(block, var_index);

      err = config_GetKeyValue(item, &key_name, &key_value);
      if(err)
        {
          LogCrit(COMPONENT_CONFIG,
                  "FSAL LOAD PARAMETER: ERROR reading key[%d] from section \"%s\" of configuration file.",
                  var_index, CONF_LABEL_FS_SPECIFIC);
          ReturnCode(ERR_FSAL_SERVERFAULT, err);
        }

      /* what parameter is it ? */

      if(!STRCMP(key_name, "my_parameter_name1"))
        {
          /* >> interpret the parameter string and fill the fs_specific_info structure << */
        }
      else if(!STRCMP(key_name, "my_parameter_name2"))
        {
          /* >> interpret the parameter string and fill the fs_specific_info structure << */
        }
      /* etc... */
      else
        {
          LogCrit(COMPONENT_CONFIG,
                  "FSAL LOAD PARAMETER: ERROR: Unknown or unsettable key: %s (item %s)",
                  key_name, CONF_LABEL_FS_SPECIFIC);
          ReturnCode(ERR_FSAL_INVAL, 0);
        }

    }

  ReturnCode(ERR_FSAL_NO_ERROR, 0);

}                               /* FSAL_load_FS_specific_parameter_from_conf */
开发者ID:ShyamsundarR,项目名称:nfs-ganesha,代码行数:69,代码来源:fsal_tools.c

示例7: same_device_check


//.........这里部分代码省略.........
			} else
			{
				/* process error */
				errptr = (char *)STRERROR(save_errno);
				tmplen = STRLEN(errptr);
				rts_error_csa(CSA_ARG(NULL) VARLSTCNT(5) ERR_GETSOCKNAMERR, 3, save_errno, tmplen, errptr);
			}
		}
		/* if both sockets not the same family then not the same device */
		if ((((sockaddr_ptr)&sockname1)->sa_family) != (((sockaddr_ptr)&sockname2)->sa_family))
			return FALSE;

		switch(((sockaddr_ptr)&sockname1)->sa_family)
		{
		case AF_INET:
		case AF_INET6:
			GETNAMEINFO((struct sockaddr *)&sockname1, socknamelen1, host_buffer1, NI_MAXHOST,
				    port_buffer1, NI_MAXSERV, NI_NUMERICHOST|NI_NUMERICSERV, errcode);
			if (0 != errcode)
			{
				RTS_ERROR_ADDRINFO(NULL, ERR_GETNAMEINFO, errcode);
				return FALSE;
			}

			GETNAMEINFO((struct sockaddr *)&sockname2, socknamelen2, host_buffer2, NI_MAXHOST,
				    port_buffer2, NI_MAXSERV, NI_NUMERICHOST|NI_NUMERICSERV, errcode);
			if (0 != errcode)
			{
				RTS_ERROR_ADDRINFO(NULL, ERR_GETNAMEINFO, errcode);
				return FALSE;
			}

			/* hosts and ports must be the same */
			if (STRCMP(host_buffer1, host_buffer2) || STRCMP(port_buffer1, port_buffer2))
				return FALSE;

			psocknamelen1 = SIZEOF(psockname1);
			if (-1 == (gsn_stat = getpeername(0, (struct sockaddr *)&psockname1,
							   (GTM_SOCKLEN_TYPE *)&psocknamelen1)))
			{
				save_errno = errno;
				errptr = (char *)STRERROR(save_errno);
				tmplen = STRLEN(errptr);
				rts_error_csa(CSA_ARG(NULL) VARLSTCNT(5) ERR_GETSOCKNAMERR, 3, save_errno, tmplen, errptr);
			}


			psocknamelen2 = SIZEOF(psockname2);
			if (-1 == (gsn_stat = getpeername(1, (struct sockaddr *)&psockname2,
							   (GTM_SOCKLEN_TYPE *)&psocknamelen2)))
			{
				save_errno = errno;
				errptr = (char *)STRERROR(save_errno);
				tmplen = STRLEN(errptr);
				rts_error_csa(CSA_ARG(NULL) VARLSTCNT(5) ERR_GETSOCKNAMERR, 3, save_errno, tmplen, errptr);
			}

			GETNAMEINFO((struct sockaddr *)&psockname1, psocknamelen1, phost_buffer1, NI_MAXHOST,
				    pport_buffer1, NI_MAXSERV, NI_NUMERICHOST|NI_NUMERICSERV, errcode);
			if (0 != errcode)
			{
				RTS_ERROR_ADDRINFO(NULL, ERR_GETNAMEINFO, errcode);
				return FALSE;
			}

			GETNAMEINFO((struct sockaddr *)&psockname2, psocknamelen2, phost_buffer2, NI_MAXHOST,
开发者ID:mihawk,项目名称:fis-gtm,代码行数:67,代码来源:same_device_check.c

示例8: mf_sync

/*
 * Sync the memory file *mfp to disk.
 * Flags:
 *  MFS_ALL	If not given, blocks with negative numbers are not synced,
 *		even when they are dirty!
 *  MFS_STOP	Stop syncing when a character becomes available, but sync at
 *		least one block.
 *  MFS_FLUSH	Make sure buffers are flushed to disk, so they will survive a
 *		system crash.
 *  MFS_ZERO	Only write block 0.
 *
 * Return FAIL for failure, OK otherwise
 */
    int
mf_sync(memfile_T *mfp, int flags)
{
    int		status;
    bhdr_T	*hp;
#if defined(SYNC_DUP_CLOSE)
    int		fd;
#endif
    int		got_int_save = got_int;

    if (mfp->mf_fd < 0)	    /* there is no file, nothing to do */
    {
	mfp->mf_dirty = FALSE;
	return FAIL;
    }

    /* Only a CTRL-C while writing will break us here, not one typed
     * previously. */
    got_int = FALSE;

    /*
     * sync from last to first (may reduce the probability of an inconsistent
     * file) If a write fails, it is very likely caused by a full filesystem.
     * Then we only try to write blocks within the existing file. If that also
     * fails then we give up.
     */
    status = OK;
    for (hp = mfp->mf_used_last; hp != NULL; hp = hp->bh_prev)
	if (((flags & MFS_ALL) || hp->bh_bnum >= 0)
		&& (hp->bh_flags & BH_DIRTY)
		&& (status == OK || (hp->bh_bnum >= 0
		    && hp->bh_bnum < mfp->mf_infile_count)))
	{
	    if ((flags & MFS_ZERO) && hp->bh_bnum != 0)
		continue;
	    if (mf_write(mfp, hp) == FAIL)
	    {
		if (status == FAIL)	/* double error: quit syncing */
		    break;
		status = FAIL;
	    }
	    if (flags & MFS_STOP)
	    {
		/* Stop when char available now. */
		if (ui_char_avail())
		    break;
	    }
	    else
		ui_breakcheck();
	    if (got_int)
		break;
	}

    /*
     * If the whole list is flushed, the memfile is not dirty anymore.
     * In case of an error this flag is also set, to avoid trying all the time.
     */
    if (hp == NULL || status == FAIL)
	mfp->mf_dirty = FALSE;

    if ((flags & MFS_FLUSH) && *p_sws != NUL)
    {
#if defined(UNIX)
# ifdef HAVE_FSYNC
	/*
	 * most Unixes have the very useful fsync() function, just what we need.
	 * However, with OS/2 and EMX it is also available, but there are
	 * reports of bad problems with it (a bug in HPFS.IFS).
	 * So we disable use of it here in case someone tries to be smart
	 * and changes os_os2_cfg.h... (even though there is no __EMX__ test
	 * in the #if, as __EMX__ does not have sync(); we hope for a timely
	 * sync from the system itself).
	 */
#  if defined(__EMX__)
   error "Don't use fsync with EMX! Read emxdoc.doc or emxfix01.doc for info."
#  endif
	if (STRCMP(p_sws, "fsync") == 0)
	{
	    if (fsync(mfp->mf_fd))
		status = FAIL;
	}
	else
# endif
	    /* OpenNT is strictly POSIX (Benzinger) */
	    /* Tandem/Himalaya NSK-OSS doesn't have sync() */
	    /* No sync() on Stratus VOS */
# if defined(__OPENNT) || defined(__TANDEM) || defined(__VOS__)
//.........这里部分代码省略.........
开发者ID:Addisonbean,项目名称:vim,代码行数:101,代码来源:memfile.c

示例9: acpi_ns_root_initialize


//.........这里部分代码省略.........
			if (!obj_desc) {
				status = AE_NO_MEMORY;
				goto unlock_and_exit;
			}

			/*
			 * Convert value string from table entry to
			 * internal representation. Only types actually
			 * used for initial values are implemented here.
			 */

			switch (init_val->type)
			{

			case ACPI_TYPE_NUMBER:

				obj_desc->number.value =
						(ACPI_INTEGER) STRTOUL (init_val->val, NULL, 10);
				break;


			case ACPI_TYPE_STRING:

				obj_desc->string.length =
						(u16) STRLEN (init_val->val);

				/*
				 * Allocate a buffer for the string.  All
				 * String.Pointers must be allocated buffers!
				 * (makes deletion simpler)
				 */
				obj_desc->string.pointer = acpi_cm_allocate (
						   (obj_desc->string.length + 1));
				if (!obj_desc->string.pointer) {
					acpi_cm_remove_reference (obj_desc);
					status = AE_NO_MEMORY;
					goto unlock_and_exit;
				}

				STRCPY (obj_desc->string.pointer, init_val->val);
				break;


			case ACPI_TYPE_MUTEX:

				obj_desc->mutex.sync_level =
						(u16) STRTOUL (init_val->val, NULL, 10);

				if (STRCMP (init_val->name, "_GL_") == 0) {
					/*
					 * Create a counting semaphore for the
					 * global lock
					 */
					status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT,
							 1, &obj_desc->mutex.semaphore);

					if (ACPI_FAILURE (status)) {
						goto unlock_and_exit;
					}
					/*
					 * We just created the mutex for the
					 * global lock, save it
					 */

					acpi_gbl_global_lock_semaphore = obj_desc->mutex.semaphore;
				}

				else {
					/* Create a mutex */

					status = acpi_os_create_semaphore (1, 1,
							   &obj_desc->mutex.semaphore);

					if (ACPI_FAILURE (status)) {
						goto unlock_and_exit;
					}
				}
				break;


			default:
				REPORT_ERROR (("Unsupported initial type value %X\n",
					init_val->type));
				acpi_cm_remove_reference (obj_desc);
				obj_desc = NULL;
				continue;
			}

			/* Store pointer to value descriptor in the Node */

			acpi_ns_attach_object (new_node, obj_desc,
					   obj_desc->common.type);
		}
	}


unlock_and_exit:
	acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
	return (status);
}
开发者ID:ahenroid,项目名称:linux-pm,代码行数:101,代码来源:nsaccess.c

示例10: ASSERT


//.........这里部分代码省略.........
	m_pszMultiple    = NULL;
	m_pszMultipleDir = NULL;

	// Parse the mask to see if it contains multiple/dual masks (ie, look for ",;!")

	TCHAR  ch;
	int    nDir   = 0;
	int    nChars = 0;
	LPTSTR pszDir = NULL;
	LPTSTR psz    = pszMask;

	while (ch = *psz++)
	{
		if ((ch == ',') || (ch == ';'))
		{
			if (pszDir)
			{
				if (m_pszMultipleDir == NULL)
					m_pszMultipleDir = pszDir;		// We need to re-point this to the mask buffer when we create it later on
			}
			else
			{
				if (m_pszMultiple == NULL)
				{
					// We will be modifying the multiple mask string - so copy it into m_szMultiple
					m_pszMultiple = m_szMultiple;
					STRNCPY(m_pszMultiple, pszMask, MAX_PATH);
				}
			}
		}
		else

		if ((ch == '|') && !pszDir)
		{
			pszDir = psz;
			nDir   = nChars;
		}

		nChars++;
	}

	BOOL fNoDirs = FALSE;

	if (pszDir)
	{
		// We have a second mask - we will need to assign m_pszDirBuffer so it can hold it
		// We also need to copy the original mask into its own buffer (we will use m_szMultiple) as we will need to replace the | with a nul!

		if (nDir)
		{
			if (m_pszMultiple == NULL)
				STRNCPY(m_szMultiple, pszMask, MAX_PATH);
				
			m_pszMask = m_szMultiple;

			ASSERT(m_szMultiple[nDir] == '|');
			m_szMultiple[nDir] = 0;
		}
		else
		{
			// We have an *empty* mask - we will display *no* files!
			m_pszMask = NULL;
			ASSERT(m_pszMultiple == NULL);
		}

		// If the directory mask contains anything - create a buffer for it - otherwise we will use the same buffers as the "file"
		int nLen = STRLEN(pszDir);

		if (nLen)
		{
			m_pszDirBuffer = new TCHAR[nLen+2];		// We may need to add 2 nuls to the end - this will be done when we parse the buffer later on
			STRCPY(m_pszDirBuffer, pszDir);
			m_pszMaskDir = m_pszDirBuffer;

			if (m_pszMultipleDir)
				m_pszMultipleDir = m_pszMaskDir;
		}
		else
		{
			// The dir mask is empty - display *no* dirs!
			fNoDirs = TRUE;
		}
	}

	if (m_pszMask)
		m_fMatchAll = (!STRCMP(m_pszMask, _T("*.*")) ||! STRCMP(m_pszMask, _T("*"))) ? TRUE : FALSE;
	else
		m_fMatchAll = FALSE;

	if (m_pszMaskDir)
		m_fMatchAllDir = (!STRCMP(m_pszMaskDir, _T("*.*")) ||! STRCMP(m_pszMaskDir, _T("*"))) ? TRUE : FALSE;
	else
		m_fMatchAllDir = !fNoDirs;
    
	if (m_pszMultiple)
		ParseMultiple(m_pszMultiple);
	
	if (m_pszMultipleDir && (m_pszMultipleDir != m_pszMultiple))
		ParseMultiple(m_pszMultipleDir);
}
开发者ID:cprineas,项目名称:VBackup,代码行数:101,代码来源:FileMatcher.cpp

示例11: GetFormatID

//Do not change these these are stored in the database
CLIPFORMAT GetFormatID(LPCTSTR cbName)
{
	if(STRCMP(cbName, _T("CF_TEXT")) == 0)
		return CF_TEXT;
	else if(STRCMP(cbName, _T("CF_METAFILEPICT")) == 0)
		return CF_METAFILEPICT;
	else if(STRCMP(cbName, _T("CF_SYLK")) == 0)
		return CF_SYLK;
	else if(STRCMP(cbName, _T("CF_DIF")) == 0)
		return CF_DIF;
	else if(STRCMP(cbName, _T("CF_TIFF")) == 0)
		return CF_TIFF;
	else if(STRCMP(cbName, _T("CF_OEMTEXT")) == 0)
		return CF_OEMTEXT;
	else if(STRCMP(cbName, _T("CF_DIB")) == 0)
		return CF_DIB;
	else if(STRCMP(cbName, _T("CF_PALETTE")) == 0)
		return CF_PALETTE;
	else if(STRCMP(cbName, _T("CF_PENDATA")) == 0)
		return CF_PENDATA;
	else if(STRCMP(cbName, _T("CF_RIFF")) == 0)
		return CF_RIFF;
	else if(STRCMP(cbName, _T("CF_WAVE")) == 0)
		return CF_WAVE;
	else if(STRCMP(cbName, _T("CF_UNICODETEXT")) == 0)
		return CF_UNICODETEXT;
	else if(STRCMP(cbName, _T("CF_ENHMETAFILE")) == 0)
		return CF_ENHMETAFILE;
	else if(STRCMP(cbName, _T("CF_HDROP")) == 0)
		return CF_HDROP;
	else if(STRCMP(cbName, _T("CF_LOCALE")) == 0)
		return CF_LOCALE;
	else if(STRCMP(cbName, _T("CF_OWNERDISPLAY")) == 0)
		return CF_OWNERDISPLAY;
	else if(STRCMP(cbName, _T("CF_DSPTEXT")) == 0)
		return CF_DSPTEXT;
	else if(STRCMP(cbName, _T("CF_DSPBITMAP")) == 0)
		return CF_DSPBITMAP;
	else if(STRCMP(cbName, _T("CF_DSPMETAFILEPICT")) == 0)
		return CF_DSPMETAFILEPICT;
	else if(STRCMP(cbName, _T("CF_DSPENHMETAFILE")) == 0)
		return CF_DSPENHMETAFILE;
	
	
	return ::RegisterClipboardFormat(cbName);
}
开发者ID:CyberShadow,项目名称:Ditto,代码行数:47,代码来源:Misc.cpp

示例12: hddfmt_start

static void hddfmt_start()
{
	UINT8 back_saved;
	win_popup_choice_t choice;
	UINT8 mode;
	struct dvr_HDD_info hdd_info;
	char volume_name[48];
	char osd_name[48];
	char hint[64];
	BOOL ret;

	disk_format_mode_num = get_fsystem_installed(disk_mode, 8);
	//sprintf(temp, "%s", disk_mode[input]);

	storage_index_to_osd_string((UINT8)hddfmt_cur_volume,osd_name);	
	sprintf(hint, "Are you sure to format the %s?", osd_name);

	if(disk_format_mode_num == 1)
	{
		win_compopup_init(WIN_POPUP_TYPE_OKNO);
		win_compopup_set_btnstr_ext(0, disk_mode[0]);
		win_compopup_set_default_choice(WIN_POP_CHOICE_NO);		
	}
	else if(disk_format_mode_num == 2)
	{
		win_compopup_init(WIN_POPUP_TYPE_OKNOCANCLE);
		win_compopup_set_btnstr_ext(0, disk_mode[0]);
		win_compopup_set_btnstr_ext(1, disk_mode[1]);
		win_compopup_set_default_choice(WIN_POP_CHOICE_CANCEL);		
	}
	win_compopup_set_msg(hint, NULL, 0);
	choice = win_compopup_open_ext(&back_saved);

	if(((disk_format_mode_num == 1) && (choice == WIN_POP_CHOICE_YES)) || ((disk_format_mode_num == 2) && ((choice == WIN_POP_CHOICE_YES) || (choice == WIN_POP_CHOICE_NO))))
	{
		if(choice == WIN_POP_CHOICE_YES)
			mode = 1;
		else
			mode = 2;

		storage_index2volume((UINT8)hddfmt_cur_volume,volume_name);
		storage_add_parent_dir(volume_name);		
		win_compopup_init(WIN_POPUP_TYPE_SMSG);
		win_compopup_set_frame(GET_MID_L(286), GET_MID_T(130), 286, 130);
		win_compopup_set_msg_ext("formating wait!",NULL,0);
		win_compopup_open_ext(&back_saved);
		ret = pvr_format_multi_hdd(mode, volume_name);
		win_compopup_smsg_restoreback();

		if(!ret) 		
		{
			win_compopup_init(WIN_POPUP_TYPE_OK);
			sprintf(hint, "Format %s error?", osd_name);
			win_compopup_set_msg(hint, NULL, 0);
			win_compopup_set_default_choice(WIN_POP_CHOICE_CANCEL);		
			win_compopup_open_ext(&back_saved);
			return;
		}

		if(STRCMP((char *)pvr_get_mout_prefix(), volume_name)==0)
		{
			if(pvr_get_HDD_info(&hdd_info))
			{
				api_pvr_check_level(&hdd_info);		
				ap_clear_all_message();//or usb reflash msg maybe send fail
				pvr_evnt_callback(0, PVR_HDD_FORMATTED);
			}		
		}
		win_hddfmt_draw_disk_infor();
	}
}
开发者ID:Janesak1977,项目名称:ali3602,代码行数:71,代码来源:win_pvr_hdd_format.c

示例13: nmt_mount_share

//
// Return 1 if path can be mounted.
// the share name is the folder after the NETWORK_SHARE sub folder.
// Then the nmt settings are inspected to get the full mount definition.
//
// First try to ping the host.
//
// If that doesnt work and using SMB/cifs then try to use nbtscan to
// resolve wins names.
//
// The current_mount_status is passed in case the share is alread present
// in /etc/mtab. If it is not - try to mount it, if it is, then check for timeouts.
static int nmt_mount_share(char *path,char *current_mount_status)
{
    int result = 0;

    char *link_prefix=NULL;
    char *share_name = util_basename(path);
    HTML_LOG(0,"mount path=[%s] share_name [%s] current status [%s]",path,share_name,current_mount_status);
    // eg "abc"

    char index = get_link_index("servname",share_name);
    if (index) {
        link_prefix="servlink";
    } else {
        index = get_link_index("netfs_name",share_name);
        if (index) {
            link_prefix="netfs_url";
        }
    }

    if (index) {
        char *key;
        ovs_asprintf(&key,"%s%c",link_prefix,index);

        char *serv_link = setting_val(key);
        // Look for corresponding variable servlinkN
		
		HTML_LOG(0,"DEMOTE mount %s [%s]",link_prefix,serv_link);
        FREE(key);

        char *link = get_pingable_link(serv_link);

        if (!link) {

            set_mount_status(path,MOUNT_STATUS_BAD);
        } else if (STRCMP(current_mount_status,MOUNT_STATUS_NOT_IN_MTAB) == 0) {

            char *user = get_link_user(serv_link);
            char *passwd = get_link_passwd(serv_link);
            NETFSProtocol proto = get_link_protocol(serv_link);

            char *cmd = get_mount_command(proto,link,path,user,passwd);

            FREE(user);
            FREE(passwd);

            if (cmd ) {
                long t = time(NULL);
                int mount_result = util_system(cmd);

                // Mount prints detailed error to stdout but just returns exit codes
                // 0(OK) , 1(Bad args?) OR  0xFF00 (Something else).
                // So we cant tell exactly why it failed without scraping
                // stdout.
                // Eg if mount display 'Device or resource Busy' it doesnt return EBUSY(16)
                //
                // Also trying to use native mount() function is hard work
                // (it does kernel space work but not other stuff - update /etc/mtab etc?)
                //
                // So I've taken a big liberty here and assumed that if the mount returns
                // immediately that it worked.
                // This obviously is risky of the mount failed due to bad parameters.
                switch(mount_result) {
                case 0:
                    result = 1;
                    break;
                case 0xFF00:
                    // some mount error occured. If it occured in less than 1 second
                    // just assume its a device busy and continue happily assuming it
                    // is already mounted.
                    if (time(NULL) - t <= 5) {
                        HTML_LOG(0,"mount [%s] failed quickly - assume all is ok",cmd);
                        result = 1;
                    } else {
                        HTML_LOG(0,"mount [%s] failed slowly - assume the worst ",cmd);
                        result = 0;
                    }
                    break;
                default:
                    HTML_LOG(0,"mount [%s] unknown error - assume the worst ",cmd);
                    //even though mount failed - add it to the list to avoid repeat attempts.
                    result = 0;
                }
                set_mount_status(path,(result ? MOUNT_STATUS_OK : MOUNT_STATUS_BAD));

                FREE(cmd);
            }

        } else if (STRCMP(current_mount_status,MOUNT_STATUS_IN_MTAB) == 0) {
//.........这里部分代码省略.........
开发者ID:Sproglet,项目名称:oversight,代码行数:101,代码来源:mount.c

示例14: remote_ui_raw_line

static void remote_ui_raw_line(UI *ui, Integer grid, Integer row,
                               Integer startcol, Integer endcol,
                               Integer clearcol, Integer clearattr,
                               Boolean wrap, const schar_T *chunk,
                               const sattr_T *attrs)
{
  UIData *data = ui->data;
  if (ui->ui_ext[kUILinegrid]) {
    Array args = ARRAY_DICT_INIT;
    ADD(args, INTEGER_OBJ(grid));
    ADD(args, INTEGER_OBJ(row));
    ADD(args, INTEGER_OBJ(startcol));
    Array cells = ARRAY_DICT_INIT;
    int repeat = 0;
    size_t ncells = (size_t)(endcol-startcol);
    int last_hl = -1;
    for (size_t i = 0; i < ncells; i++) {
      repeat++;
      if (i == ncells-1 || attrs[i] != attrs[i+1]
          || STRCMP(chunk[i], chunk[i+1])) {
        Array cell = ARRAY_DICT_INIT;
        ADD(cell, STRING_OBJ(cstr_to_string((const char *)chunk[i])));
        if (attrs[i] != last_hl || repeat > 1) {
          ADD(cell, INTEGER_OBJ(attrs[i]));
          last_hl = attrs[i];
        }
        if (repeat > 1) {
          ADD(cell, INTEGER_OBJ(repeat));
        }
        ADD(cells, ARRAY_OBJ(cell));
        repeat = 0;
      }
    }
    if (endcol < clearcol) {
      Array cell = ARRAY_DICT_INIT;
      ADD(cell, STRING_OBJ(cstr_to_string(" ")));
      ADD(cell, INTEGER_OBJ(clearattr));
      ADD(cell, INTEGER_OBJ(clearcol-endcol));
      ADD(cells, ARRAY_OBJ(cell));
    }
    ADD(args, ARRAY_OBJ(cells));

    push_call(ui, "grid_line", args);
  } else {
    for (int i = 0; i < endcol-startcol; i++) {
      remote_ui_cursor_goto(ui, row, startcol+i);
      remote_ui_highlight_set(ui, attrs[i]);
      remote_ui_put(ui, (const char *)chunk[i]);
      if (utf_ambiguous_width(utf_ptr2char(chunk[i]))) {
        data->client_col = -1;  // force cursor update
      }
    }
    if (endcol < clearcol) {
      remote_ui_cursor_goto(ui, row, endcol);
      remote_ui_highlight_set(ui, (int)clearattr);
      // legacy eol_clear was only ever used with cleared attributes
      // so be on the safe side
      if (clearattr == 0 && clearcol == Columns) {
        Array args = ARRAY_DICT_INIT;
        push_call(ui, "eol_clear", args);
      } else {
        for (Integer c = endcol; c < clearcol; c++) {
          remote_ui_put(ui, " ");
        }
      }
    }
  }
}
开发者ID:roxma,项目名称:neovim,代码行数:68,代码来源:ui.c

示例15: DoPyCommand

/*
 * External interface
 */
static void
DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg)
{
#if defined(MACOS) && !defined(MACOS_X_UNIX)
	GrafPtr		oldPort;
#endif
#if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
	char		*saved_locale;
#endif
	PyObject		*cmdstr;
	PyObject		*cmdbytes;
	PyGILState_STATE	pygilstate;

#if defined(MACOS) && !defined(MACOS_X_UNIX)
	GetPort(&oldPort);
	/* Check if the Python library is available */
	if ((Ptr)PyMac_Initialize == (Ptr)kUnresolvedCFragSymbolAddress)
		goto theend;
#endif
	if (Python3_Init())
		goto theend;

	init_range(arg);

	Python_Release_Vim();	    /* leave vim */

#if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
	/* Python only works properly when the LC_NUMERIC locale is "C". */
	saved_locale = setlocale(LC_NUMERIC, NULL);
	if (saved_locale == NULL || STRCMP(saved_locale, "C") == 0)
		saved_locale = NULL;
	else {
		/* Need to make a copy, value may change when setting new locale. */
		saved_locale = (char *)vim_strsave((char_u *)saved_locale);
		(void)setlocale(LC_NUMERIC, "C");
	}
#endif

	pygilstate = PyGILState_Ensure();

	/* PyRun_SimpleString expects a UTF-8 string. Wrong encoding may cause
	 * SyntaxError (unicode error). */
	cmdstr = PyUnicode_Decode(cmd, strlen(cmd),
							  (char *)ENC_OPT, CODEC_ERROR_HANDLER);
	cmdbytes = PyUnicode_AsEncodedString(cmdstr, "utf-8", CODEC_ERROR_HANDLER);
	Py_XDECREF(cmdstr);

	run(PyBytes_AsString(cmdbytes), arg, &pygilstate);
	Py_XDECREF(cmdbytes);

	PyGILState_Release(pygilstate);

#if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
	if (saved_locale != NULL) {
		(void)setlocale(LC_NUMERIC, saved_locale);
		vim_free(saved_locale);
	}
#endif

	Python_Lock_Vim();		    /* enter vim */
	PythonIO_Flush();
#if defined(MACOS) && !defined(MACOS_X_UNIX)
	SetPort(oldPort);
#endif

theend:
	return;	    /* keeps lint happy */
}
开发者ID:tonymagro,项目名称:viw,代码行数:71,代码来源:if_python3.c


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