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

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

51自学网 2021-06-01 20:21:54
  C++
这篇教程C++ DIE函数代码示例写得很实用,希望能帮到您。

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

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

示例1: string_linked_list_init

StringLinkedList *string_linked_list_init(void){    StringLinkedList *sll = malloc(sizeof(StringLinkedList));    if (sll == NULL) {        DIE("ERROR: Not enough memory to allocate StringLinkedList")    }    sll->head = NULL;    sll->tail = NULL;    sll->len = 0;        return sll;}
开发者ID:zuigon,项目名称:version_sorter,代码行数:13,


示例2: parse_version_word

static voidparse_version_word(char *word, StringLinkedList *sll){    if (expr == NULL) {        setup_version_regex();    }        int ovecsize = 0;    if (pcre_fullinfo(expr, NULL, PCRE_INFO_CAPTURECOUNT, &ovecsize) != 0) {        DIE("ERROR: Problem calling pcre_fullinfo")    }    ovecsize = (ovecsize + 1) * 3;        int *ovector = calloc(ovecsize, sizeof(int));    if (ovector == NULL) {        DIE("ERROR: Not enough memory to allocate ovector")    }    int offset = 0;    int flags = 0;    char *part;    while (0 < pcre_exec(expr, 0, word, strlen(word), offset, flags, ovector, ovecsize)) {                part = malloc((WORD_MAX_LEN+1) * sizeof(char));        if (part == NULL) {            DIE("ERROR: Not enough memory to allocate word")        }        snprintf(part, WORD_MAX_LEN+1, "%.*s", ovector[1]-ovector[0], word+ovector[0]);        string_linked_list_append(sll, part);                offset = ovector[1];        flags |= PCRE_NOTBOL;    }        free(ovector);}
开发者ID:zuigon,项目名称:version_sorter,代码行数:39,


示例3: computeReserve

/*	Compute reduced heap size by reserving area and rounding down to	nearest page.*/doublecomputeReserve(double rate, int phases){	assert(rate > 1.0);	if (phases == 0)	/* not concurrent */		return 0.0;	else if (phases == 1) /* concurrent */		return rate / (rate + 1.0);	else if (phases == 2) /* concurrent - non-committing, committing */		return (rate + 1.0) / (rate * rate + rate + 1.0);	DIE("invalid phases");	return 0.0;	/* NOTREACHED */}
开发者ID:RobertHarper,项目名称:TILT-Compiler,代码行数:17,


示例4: WaitChild

int WaitChild(pid_t pid, const char *name) {  int err, status;  do {    err = waitpid(pid, &status, 0);  } while (err == -1 && errno == EINTR);  if (err == -1) {    DIE("wait on %s (pid %d) failed/n", name, pid);  }  return status;}
开发者ID:CydeWeys,项目名称:bazel,代码行数:13,


示例5: add_to_common_env

void add_to_common_env(char *key, char *value){#ifndef EXCLUDE_CGI    common_cgi_env = realloc(common_cgi_env, (common_cgi_env_count + 2) * (sizeof(char *)));    if (common_cgi_env== NULL) {        DIE("Unable to allocate memory for common CGI environment variable.");    }    common_cgi_env[common_cgi_env_count] = env_gen_extra(key,value, 0);    if (common_cgi_env[common_cgi_env_count] == NULL) {        /* errors already reported */        DIE("memory allocation failure in add_to_common_env");    }    common_cgi_env[++common_cgi_env_count] = NULL;    /* I find it hard to believe that somebody would actually     * make 90+ *common* CGI variables, but it's always better     * to be safe.     */    if (common_cgi_env_count > CGI_ENV_MAX) {        DIE("far too many common CGI environment variables added.");    }#endif // !EXCLUDE_CGI}
开发者ID:jameshilliard,项目名称:WECB-BH-GPL,代码行数:22,


示例6: loadRom

static void loadRom(){	const char * file = S9xGetFilename(FILE_ROM);	printf("ROM: %s/n", file);	if (!Memory.LoadROM(file))		DIE("Loading ROM failed");		file = S9xGetFilename(FILE_SRAM);	printf("SRAM: %s/n", file);	Memory.LoadSRAM(file); }
开发者ID:dtzWill,项目名称:supernes,代码行数:13,


示例7: glfwWindowHint

Window::Window(Game* parent){  width = height = 600;  game = parent;  glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);  glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);  glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);  windowHandle = glfwCreateWindow(width, height, "Grass", NULL, NULL);  glfwSetWindowPos(windowHandle,800,30);  if (!windowHandle)    DIE("Failed to create window");  glfwMakeContextCurrent(windowHandle);}
开发者ID:rspencer01,项目名称:grass,代码行数:13,


示例8: recv_c

int recv_c(int socket, byte *recvbuf, int bufsize) {    LOG_DEBUG(TAG_CMD, "Receiving command");    int bytes_total = 0;    int bytes_received = 0;    int bytes_missing = CMD_HEADER_LEN;    uint16_t pl_len = 0;    // Receive header    while (bytes_missing > 0) {        bytes_received = recv(socket, recvbuf+bytes_total, bytes_missing, 0);        if (bytes_received == 0) {            return 0;        } else if (bytes_total > bufsize) {            DIE(TAG_CMD, "Recvbuf overflow");        }        bytes_total += bytes_received;        bytes_missing -= bytes_received;    }    // Check length of the packet and receive more data if needed    memcpy(&pl_len, recvbuf+CMD_PL_LEN_OFFSET, sizeof(uint16_t));    pl_len = ntohs(pl_len);    bytes_received = 0;    bytes_missing = pl_len;    while (bytes_missing > 0) {        bytes_received = recv(socket, recvbuf+bytes_total, bytes_missing, 0);        if (bytes_received == 0) {            LOG_WARN(TAG_CMD, "GUI disconnected");            return 0;        } else if (bytes_total > bufsize) {            DIE(TAG_CMD, "Recvbuf overflow");        }        bytes_total += bytes_received;        bytes_missing -= bytes_received;    }        LOG_DEBUG(TAG_CMD, "Received %d bytes", bytes_total);    return bytes_total;}
开发者ID:hmhagberg,项目名称:DHT,代码行数:39,


示例9: close_files

static void close_files(void){	size_t n_files = sizeof(files) / sizeof(files[0]);	size_t i;	int rc;	for (i = 0; i < n_files; i++) {		rc = close(fds[i]);		DIE(rc < 0, "close");	}	free(fds);}
开发者ID:alexandrucomanescu,项目名称:ASCPublic,代码行数:13,


示例10: show_time

/* based on show_diff_time from eachfile.c */void show_time(FILE *out, char T, time_t val){    char	buf[ELC_TIMEBUFSIZ];    putc(T, out);    putc('(', out);    if (! strftime(buf, ELC_TIMEBUFSIZ, "%Y%m%d-%H%M%S", localtime(&val)) )      DIE("strftime");    fputs(buf, out);    fputs(") ", out);}
开发者ID:cbjohns,项目名称:integrit,代码行数:14,


示例11: flytec_pbrtr

	static voidflytec_pbrtr(flytec_t *flytec, track_t *track, void (*callback)(void *, const char *), void *data){	char buf[9];	if (snprintf(buf, sizeof buf, "PBRTR,%02d", track->index) != 8)		DIE("sprintf", 0);	flytec_puts_nmea(flytec, buf);	flytec_expectc(flytec, XOFF);	char line[1024];	while (flytec_gets(flytec, line, sizeof line))		callback(data, line);	flytec_expectc(flytec, XON);}
开发者ID:idaohang,项目名称:gpsbabel-flytec,代码行数:13,


示例12: flytec_puts_nmea

	static voidflytec_puts_nmea(flytec_t *flytec, char *s){	int checksum = 0;	char *p;	for (p = s; *p; ++p)		checksum ^= (unsigned char) *p;	int len = strlen(s) + 7;	char *buf = xmalloc(len);	memset(buf, 0, len);	if (snprintf(buf, len, "$%s*%02X/r/n", s, checksum) != len - 1)		DIE("snprintf", 0);	if (flytec->logfile)		fprintf(flytec->logfile, "> %s", buf);	int rc;	do {		rc = write(flytec->fd, buf, len);	} while (rc == -1 && errno == EINTR);	if (rc == -1)		DIE("write", errno);	free(buf);}
开发者ID:idaohang,项目名称:gpsbabel-flytec,代码行数:22,


示例13: create_iocp_accept

static void create_iocp_accept(void){	BOOL bRet;	memset(&ac, 0, sizeof(ac));	/* Create simple socket for acceptance */	ac.sockfd = socket(PF_INET, SOCK_STREAM, 0);	DIE(ac.sockfd == INVALID_SOCKET, "socket");	/* Launch overlapped connection accept through AcceptEx. */	bRet = AcceptEx(			listenfd,			ac.sockfd,			ac.buffer,			0,			128,			128,			&ac.len,			&ac.ov);	DIE(bRet == FALSE && WSAGetLastError() != ERROR_IO_PENDING, "AcceptEx");}
开发者ID:adrianacaciur,项目名称:PiTV,代码行数:22,


示例14: pdo_sqlsrv_handle_stmt_error

// PDO error handler for the statement context.bool pdo_sqlsrv_handle_stmt_error( sqlsrv_context& ctx, unsigned int sqlsrv_error_code, bool warning TSRMLS_DC,                                   va_list* print_args ){    pdo_stmt_t* pdo_stmt = reinterpret_cast<pdo_stmt_t*>( ctx.driver());    SQLSRV_ASSERT( pdo_stmt != NULL && pdo_stmt->dbh != NULL, "pdo_sqlsrv_handle_stmt_error: Null statement or dbh passed" );    sqlsrv_error_auto_ptr error;    if( sqlsrv_error_code != SQLSRV_ERROR_ODBC ) {        core_sqlsrv_format_driver_error( ctx, get_error_message( sqlsrv_error_code ), error, SEV_ERROR TSRMLS_CC, print_args );    }    else {        bool err = core_sqlsrv_get_odbc_error( ctx, 1, error, SEV_ERROR TSRMLS_CC );        SQLSRV_ASSERT( err == true, "No ODBC error was found" );    }    SQLSRV_STATIC_ASSERT( sizeof( error->sqlstate ) <= sizeof( pdo_stmt->error_code ));    strcpy_s( pdo_stmt->error_code, sizeof( pdo_stmt->error_code ), reinterpret_cast<const char*>( error->sqlstate ));    switch( pdo_stmt->dbh->error_mode ) {        case PDO_ERRMODE_EXCEPTION:            if( !warning ) {                pdo_sqlsrv_throw_exception( error TSRMLS_CC );            }            ctx.set_last_error( error );            break;        case PDO_ERRMODE_WARNING:            if( !warning ) {                unsigned int msg_len = strlen( reinterpret_cast<const char*>( error->native_message )) + SQL_SQLSTATE_BUFSIZE                     + MAX_DIGITS + 1;                sqlsrv_malloc_auto_ptr<char> msg;                msg = static_cast<char*>( sqlsrv_malloc( msg_len ));                core_sqlsrv_format_message( msg, msg_len, WARNING_TEMPLATE, error->sqlstate, error->native_code,                                             error->native_message );                php_error( E_WARNING, msg );                sqlsrv_free( msg );            }            ctx.set_last_error( error );            break;        case PDO_ERRMODE_SILENT:            ctx.set_last_error( error );            break;        default:            DIE( "Unknown error mode. %1!d!", pdo_stmt->dbh->error_mode );            break;    }    // return error ignored = true for warnings.    return ( warning ? true : false );}
开发者ID:Aymax,项目名称:msphpsql,代码行数:52,


示例15: print

void print(elem *hashtable, int size, char *file_name){	int i;	FILE *fd;	if(file_name != NULL)	{		fd = fopen(file_name, "a");		DIE(fd == NULL, "[print] Error opening file.");	}	for(i = 0; i < size; i++)	{		if(hashtable[i].next != NULL)		{			elem *temp = hashtable[i].next;						if(file_name != NULL)			{				while(temp != NULL)				{					if(temp->next == NULL)						fprintf(fd, "%s", temp->value);				/* Print without the last space */					else						fprintf(fd, "%s ", temp->value);					temp = temp->next;				}			}else			{				while(temp != NULL)				{					if(temp->next == NULL)						printf("%s", temp->value);					else						printf("%s ", temp->value);					temp = temp->next;				}			}			if(file_name != NULL)				fprintf(fd, "/n");			else				printf("/n");		}	}	if(file_name != NULL)		fclose(fd);}
开发者ID:smacrineanu,项目名称:hashtable-multi_platform,代码行数:51,


示例16: switch

void CNPC::DoWCMilitiaAI() {   if (DIE(1000) <= 4) {	switch (this->GetVnum()) {	   case 13003:		this->AddCommand("emote works on his backstab.");		break;	   case 13005:		this->AddCommand("emote takes a shot at a target and hits it's mark.");		this->AddCommand("smile");		break;	   case 13006:		this->AddCommand("emote takes a shot at a target and misses wildly.");		this->AddCommand("frown");		break;	   case 13007:		this->AddCommand("emote works hard on his next invention, scribbling on a piece of paper.");		break;	   case 13009:		switch (DIE(3)) {		   case 1:			this->AddCommand("emote sits and eats quietly.");			break;		   case 2:			this->AddCommand("say Man, working out really builds up the appetite.");			break;		   case 3:			this->AddCommand("say I liked Mom's cooking much better.");			break;		}		break;	   case 13002:		this->AddCommand("emote sings... I wanna make love to you woman... I wanna lay you down by the fire..");		break;	   default:		break;	}   }}
开发者ID:cmdc0de,项目名称:WolfshadeMud,代码行数:38,


示例17: my_mmap

mem_tmy_mmap(int size, int prot){	caddr_t start = NULL;	static int fd = -1;	int flags;	mem_t mapped;#ifdef sparc	{		if (fd == -1)			if ((fd = open("/dev/zero", O_RDWR)) == -1) {				perror("/dev/zero");				DIE("out of memory");			}		flags = MAP_PRIVATE;	}#else	flags = MAP_ANONYMOUS;#endif#ifdef sparc	/*		We'd like to use on-demand allocation if the OS supports it.		Currently, MAP_NORESERVE is not POSIX.  If other OSs do not		support it, then we should think about implementing a scheme		where Heap_t structures are reallocated to allow for growth.	*/	flags |= MAP_NORESERVE;#endif	mapped = (mem_t) mmap(start, size, prot, flags, fd, 0);	if (mapped == (mem_t) -1) {		fprintf(stderr,"mmap %d failed: %s/n", size, strerror(errno));		DIE("out of memory");	}	if (diag)		fprintf(stderr,"mmap %d succeeded with mapped = %lx, prot = %d/n",			size, (long)mapped, prot);	return mapped;}
开发者ID:RobertHarper,项目名称:TILT-Compiler,代码行数:38,


示例18: cmd_crop

intcmd_crop(mpd_unused int argc, mpd_unused char **argv, struct mpd_connection *conn){	struct mpd_status *status = getStatus( conn );	int length = mpd_status_get_queue_length(status) - 1;	if (length < 0) {		mpd_status_free(status);		DIE( "A playlist longer than 1 song in length is required to crop./n" );	} else if (mpd_status_get_state(status) == MPD_STATE_PLAY ||		   mpd_status_get_state(status) == MPD_STATE_PAUSE) {		if (!mpd_command_list_begin(conn, false))			printErrorAndExit(conn);		while( length >= 0 )		{			if (length != mpd_status_get_song_pos(status)) {				mpd_send_delete(conn, length);			}			length--;		}		mpd_status_free(status);		if (!mpd_command_list_end(conn) || !mpd_response_finish(conn))			printErrorAndExit(conn);		return ( 0 );	} else {		mpd_status_free(status);		DIE( "You need to be playing to crop the playlist/n" );	}}
开发者ID:somecommand,项目名称:mpc,代码行数:38,


示例19: cmd_crop

intcmd_crop(mpd_unused int argc, mpd_unused char **argv, mpd_Connection *conn){	mpd_Status *status = getStatus( conn );	int length = ( status->playlistLength - 1 );	if( status->playlistLength == 0 ) {		mpd_freeStatus(status);		DIE( "You have to have a playlist longer than 1 song in length to crop" );	} else if( status->state == 3 || status->state == 2 ) { /* If playing or paused */		mpd_sendCommandListBegin( conn );		printErrorAndExit( conn );		while( length >= 0 )		{			if( length != status->song )			{				mpd_sendDeleteCommand( conn, length );				printErrorAndExit( conn );			}			length--;		}		mpd_sendCommandListEnd( conn );		my_finishCommand( conn );		mpd_freeStatus( status );		return ( 0 );	} else {		mpd_freeStatus(status);		DIE( "You need to be playing to crop the playlist/n" );	}}
开发者ID:OpenInkpot-archive,项目名称:iplinux-mpc,代码行数:38,


示例20: handle_new_connection

static void handle_new_connection(OVERLAPPED *ovp){	struct connection *conn;	char abuffer[64];	HANDLE hRet;	int rc;	rc = setsockopt(			ac.sockfd,			SOL_SOCKET,			SO_UPDATE_ACCEPT_CONTEXT,			(char *) &listenfd,			sizeof(listenfd)		  );	DIE(rc < 0, "setsockopt");	rc = get_peer_address(ac.sockfd, abuffer, 64);	if (rc < 0) {		ERR("get_peer_address");		return;	}	dlog(LOG_DEBUG, "Accepted connection from %s/n", abuffer);	/* Instantiate new connection handler. */	conn = connection_create(ac.sockfd);	/* Add socket to IoCompletionPort. */	hRet = w_iocp_add_key(iocp, (HANDLE) conn->sockfd, (ULONG_PTR) conn);	DIE(hRet != iocp, "w_iocp_add_key");	/* Schedule receive operation. */	connection_schedule_socket_receive(conn);	/* Use AcceptEx to schedule new connection acceptance. */	create_iocp_accept();}
开发者ID:adrianacaciur,项目名称:PiTV,代码行数:38,


示例21: main

int main(int argc, char **argv) {	FILE *in ;	MATRIX m ;	int j, i ;	if(argc != 2 ) 		DIE("Missing parameter", 1) ;	in = fopen(argv[1], "r") ;	if(!in)		DIE("Could not open file", 2) ;	read_file(in, &m) ;	fclose(in) ;	print_matrix(&m) ;	printf("========/n") ;	matrix_to_entity(&m)  ;	print_matrix(&m) ;	free_matrix(&m) ;		return 0 ;}
开发者ID:surma-dump,项目名称:solvematrix,代码行数:23,


示例22: MapFile

LPVOID MapFile(HANDLE hFile, DWORD size) {	HANDLE hFileMap;	LPVOID p;	hFileMap = CreateFileMapping(			hFile,			NULL,			PAGE_READWRITE,			0,			size,			NULL);	DIE(hFileMap == NULL, "CreateFileMapping");	p = MapViewOfFile(			hFileMap,			FILE_MAP_ALL_ACCESS,			0,			0,			0);	DIE(p == NULL, "MapViewOfFile");	return p;}
开发者ID:alexandrucomanescu,项目名称:ASCPublic,代码行数:23,


示例23: do_block

static voiddo_block(const void *in, size_t len, size_t buf_len, size_t offset,         size_t fp_len, int action, int options) {  switch (action) {  case BMZ_A_PACK:    do_pack(in, len, buf_len, offset, fp_len, options);    break;  case BMZ_A_UNPACK:    do_unpack(in, len, buf_len);    break;  default:    DIE("unknown action: %d", action);  }}
开发者ID:StevenLudwig,项目名称:hypertable,代码行数:14,


示例24: cmd_disable

intcmd_disable(mpd_unused int argc, char **argv, mpd_Connection *conn){	int arg;        if( ! parse_int( argv[0], &arg ) || arg <= 0 ) {		DIE( "Not a positive integer/n" );	} else {		mpd_sendDisableOutputCommand( conn, ( arg - 1 ) );	}	mpd_finishCommand( conn );	return cmd_outputs(0, NULL, conn);}
开发者ID:OpenInkpot-archive,项目名称:iplinux-mpc,代码行数:14,


示例25: cmd_list

int cmd_list ( int argc, char ** argv, mpd_Connection * conn ){	Constraint *constraints;	int numconstraints = 0;	int type;	int i;	char *tag;	type = get_search_type(argv[0]);	if (type < 0)		return -1;	argc -= 1;	argv += 1;	if (argc > 0) {		if (argc % 2 != 0) {			DIE("arguments must be a tag type and "			    "optional pairs of search types and queries/n");		}		numconstraints = get_constraints(argc, argv, &constraints);		if (numconstraints < 0)			return -1;	}	mpd_startFieldSearch(conn, type);	if (argc > 0) {		for (i = 0; i < numconstraints; i++) {			mpd_addConstraintSearch(conn, constraints[i].type,						charset_to_utf8(constraints[i].query));		}		free(constraints);	}	mpd_commitSearch(conn);	printErrorAndExit(conn);	while ((tag = mpd_getNextTag(conn, type))) {		printErrorAndExit(conn);		printf("%s/n", charset_from_utf8(tag));		free(tag);	}	my_finishCommand(conn);	return 0;}
开发者ID:OpenInkpot-archive,项目名称:iplinux-mpc,代码行数:50,


示例26: getIntegerParameter

int getIntegerParameter(const char* paramName, int defaultValue, int allowDefault){	char paramValue[VALUE_LENGTH];	char defaultString[VALUE_LENGTH];	sprintf(defaultString, "%d", defaultValue);	int error = getMaskedParameter(paramValue, paramName, defaultString, allowDefault);	int result = atoi(paramValue);	if(result == 0 && strcmp(paramValue, "0") != 0){		DIE("ERROR: Wrong value of %s in a configuration file ('%s'). Should be integer.", paramName, paramValue);	}	if(error != 0){		return 0;	}	return result;}
开发者ID:klyshko,项目名称:MT,代码行数:14,


示例27: more_begin

voidmore_begin(void){  static struct termios tty;  tty = stored_tty;  tty.c_lflag &= (~ECHO);  tty.c_lflag &= (~ICANON);  if (tcsetattr (0, TCSANOW, &tty) < 0)    DIE("tcsetattr");  more_active = 1;}
开发者ID:BIRD,项目名称:bird,代码行数:14,


示例28: start_task_monitor

static void start_task_monitor(void){	int rc;	setup_cpumask();	DEBUG("Starting task life cycle monitor on CPUs %s/n", nl_cpumask);	rc = send_cmd(nl_fd, nl_id,		      getpid(),		      TASKSTATS_CMD_GET, TASKSTATS_CMD_ATTR_REGISTER_CPUMASK,		      nl_cpumask, strlen(nl_cpumask) + 1);	if (rc < 0)		DIE("send cmd failed with error %d/n", rc);}
开发者ID:el8,项目名称:nlmon,代码行数:14,


示例29: sendto_ok

static void sendto_ok(void) {	int sockfd;	struct sockaddr_sw local_addr;	struct sockaddr_sw remote_addr;	ssize_t bytes_sent;	char buffer[BUFSIZ];	int rc;	fill_sockaddr_sw(&local_addr, &remote_addr, "127.0.0.1", "myHash", "127.0.0.1");	sockfd = sw_socket(PF_INET, SOCK_DGRAM, IPPROTO_SWIFT);	DIE(sockfd < 0, "sw_socket");	rc = sw_bind(sockfd, (struct sockaddr *) &local_addr, sizeof(local_addr));	DIE(rc < 0, "sw_bind");	bytes_sent = sw_sendto(sockfd, buffer, BUFSIZ, 0, (struct sockaddr *) &remote_addr, sizeof(remote_addr));		perror("sw_sendto");	test( bytes_sent >= 0 );}
开发者ID:paulvlase,项目名称:mptp,代码行数:23,


示例30: cmd_volume

intcmd_volume(int argc, char **argv, struct mpd_connection *conn){	struct int_value_change ch;	if (argc == 1) {		if (!parse_int_value_change(argv[0], &ch))			DIE("/"%s/" is not an integer/n", argv[0]);	} else {		struct mpd_status *status = getStatus(conn);		if (mpd_status_get_volume(status) >= 0)			printf("volume:%3i%c/n",			       mpd_status_get_volume(status), '%');		else			printf("volume: n/a/n");		mpd_status_free(status);		return 0;	}	if (ch.is_relative) {#if LIBMPDCLIENT_CHECK_VERSION(2,9,0)		if (mpd_connection_cmp_server_version(conn, 0, 18, 0) >= 0) {			/* MPD 0.18 knows the "volume" command for			   relative changes */			if (!mpd_run_change_volume(conn, ch.value))				printErrorAndExit(conn);			return 1;		}#endif		struct mpd_status *status = getStatus(conn);		int old_volume = mpd_status_get_volume(status);		mpd_status_free(status);		ch.value += old_volume;		if (ch.value < 0)			ch.value = 0;		else if (ch.value > 100)			ch.value = 100;		if (ch.value == old_volume)			return 1;	}	if (!mpd_run_set_volume(conn, ch.value))		printErrorAndExit(conn);	return 1;}
开发者ID:daaang,项目名称:mpc,代码行数:50,



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


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