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


C++ check_debug函数代码示例

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


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

示例1: malloc

struct Connection *Database_open(const char *filename, char mode)
{
	struct Connection *conn = malloc(sizeof(struct Connection));
	check_mem(conn);
    check_debug(conn, "Memory error");

	conn->db = malloc(sizeof(struct Database));
	check_mem(conn);
    check_debug(conn->db, "Memory error");

	if(mode == 'c') {
		conn->file = fopen(filename, "w");
	} else {
		conn->file = fopen(filename, "r+");

		if(conn->file) {
			Database_load(conn);
		}
	}

	check_debug(conn->file, "Failed to open file");
error:
   if(conn->db) free(conn->db);
   if(conn->file) fclose(conn->file);
}
开发者ID:nomikomu,项目名称:yadbm,代码行数:25,代码来源:yadbm.c

示例2: dl_del

bool dl_del(list_t *list, char *new_word){
	check_debug(list != NULL, "List is NULL.");
	check_debug(list->prev != NULL && list->next != NULL,
		"List is empty.");
	check_debug(list->prev != list && list->next != list,
		"List is empty.");
	list_t *node = NULL;
	node = list->next;
	bool result = 0;
	while(node != list){
		list_t *next_node = node->next;
		check_debug(next_node != NULL && node->prev != NULL,
			"Invalid list, node: %s, node->prev: %s",
			next_node == NULL ? "NULL" : "VALID",
			node->prev == NULL ? "NULL" : "VALID");
		if(strcmp(node->word,new_word) == 0){
			check_debug(dl_remove(list, node) == 1, 
				"Could not delete node.");
			result = 1;
		}
		node = next_node;
	}

	return result;
error:
	return 0;
}
开发者ID:quadewarren,项目名称:cs342302,代码行数:27,代码来源:dllist.c

示例3: Dir_stream_file

int Dir_stream_file(FileRecord *file, Connection *conn)
{
    ssize_t sent = 0;
    size_t total = 0;
    off_t offset = 0;
    size_t block_size = MAX_SEND_BUFFER;

    // For the non-sendfile slowpath
    char *file_buffer = NULL;
    int nread = 0;
    int amt = 0;
    int tempfd = -1;

    int rc = Dir_send_header(file, conn);
    check_debug(rc, "Failed to write header to socket.");

    if(conn->ssl == NULL) {
        for(total = 0; fdwait(conn->fd, 'w') == 0 && total < file->sb.st_size;
            total += sent) {
            sent = Dir_send(conn->fd, file->fd, &offset, block_size);
            check_debug(sent > 0, "Failed to sendfile on socket: %d from "
                        "file %d", conn->fd, file->fd);
        }
    }
    else {
        // We have to reopen the file, so we don't get ourselves into seek
        // position trouble
        int tempfd = open((const char *)(file->full_path->data), O_RDONLY);
        check(tempfd >= 0, "Could not reopen open file");

        file_buffer = malloc(MAX_SEND_BUFFER);
        check_mem(file_buffer);

        while((nread = fdread(tempfd, file_buffer, MAX_SEND_BUFFER)) > 0) {
            for(amt = 0, sent = 0; sent < nread; sent += amt) {
                amt = conn->send(conn, file_buffer + sent, nread - sent);
                check_debug(amt > 0, "Failed to send on socket: %d from "
                            "file %d", conn->fd, tempfd);
            }
            total += nread;
        }
        free(file_buffer);
        close(tempfd); tempfd = -1;
    }
    
    check(total <= file->sb.st_size, 
            "Wrote way too much, wrote %d but size was %d",
            (int)total, (int)file->sb.st_size);

    check(total == file->sb.st_size,
            "Sent other than expected, sent: %d, but expected: %d", 
            (int)total, (int)file->sb.st_size);

    return total;

error:
    if(file_buffer) free(file_buffer);
    if(tempfd >= 0) close(tempfd);
    return -1;
}
开发者ID:bnoordhuis,项目名称:mongrel2,代码行数:60,代码来源:dir.c

示例4: xsd_type

/*	---------------------------------------------------	*/
public	struct	xml_element * xsd_type( struct xml_element * xsd, char * nptr )
{
	struct	xml_element * wptr=(struct xml_element *) 0;
	struct	xml_element * tptr=(struct xml_element *) 0;
	struct	xml_atribut * aptr;
	char 		    * vptr;
	if ( check_debug() ) { printf("xsd:type( %s )\n",nptr); }
	for (	wptr = document_element( xsd, _XSD_COMPLEX );
		wptr != (struct xml_element *) 0;
		wptr = wptr->next )
	{
		if ( strcasecmp( wptr->name, _XSD_COMPLEX ) )
			continue;
		else if (!( aptr = document_atribut( wptr, _XSD_NAME ) ))
			continue;
		else if (!( aptr->value ))
			continue;
		else if (!( vptr = occi_unquoted_value( aptr->value ) ))
			continue;
		else if (!( strcmp( vptr, nptr ) ))
		{
			liberate( vptr );
			return( wptr );
		}
		else
		{
			liberate( vptr );
			continue;
		}
	}
	if ( check_debug() ) { printf("xsd:failure( attribute %s )\n",nptr); }
	return( wptr );
}
开发者ID:BillTheBest,项目名称:accords-platform,代码行数:34,代码来源:cpxsd.c

示例5: connection_proxy_req_parse

int connection_proxy_req_parse(Connection *conn)
{
    int rc = 0;
    Host *target_host = conn->req->target_host;
    Backend *req_action = conn->req->action;

    check_debug(!IOBuf_closed(conn->iob), "Client closed, goodbye.");

    rc = Connection_read_header(conn, conn->req);

    check_debug(rc > 0, "Failed to read another header.");
    error_unless(Request_is_http(conn->req), conn, 400,
            "Someone tried to change the protocol on us from HTTP.");

    Backend *found = Host_match_backend(target_host, Request_path(conn->req), NULL);
    error_unless(found, conn, 404, 
            "Handler not found: %s", bdata(Request_path(conn->req)));

    // break out of PROXY if the actions don't match
    if(found != req_action) {
        Request_set_action(conn->req, found);
        return Connection_backend_event(found, conn);
    } else {
        return HTTP_REQ;
    }

    error_response(conn, 500, "Invalid code branch, tell Zed.");
error:
    return REMOTE_CLOSE;
}
开发者ID:derdewey,项目名称:mongrel2,代码行数:30,代码来源:connection.c

示例6: IOBuf_stream

/**
 * Streams data out of the from IOBuf and into the to IOBuf
 * until it's moved total bytes between them.
 */
int IOBuf_stream(IOBuf *from, IOBuf *to, int total)
{
    int need = 0;
    int remain = total;
    int avail = 0;
    int rc = 0;
    char *data = NULL;

    if(from->len > to->len) IOBuf_resize(to, from->len);

    while(remain > 0) {
        need = remain <= from->len ? remain : from->len;

        data = IOBuf_read(from, need, &avail);
        check_debug(avail > 0, "Nothing in read buffer.");

        rc = IOBuf_send_all(to, IOBuf_start(from), avail);
        check_debug(rc == avail, "Failed to send all of the data: %d of %d", rc, avail)

        // commit whatever we just did
        check(IOBuf_read_commit(from, rc) != -1, "Final commit failed during streaming.");

        // reduce it by the given amount
        remain -= rc;
    }

    assert(remain == 0 && "Buffer math is wrong.");

    return total - remain;

error:
    return -1;
}
开发者ID:freeJim,项目名称:monserver,代码行数:37,代码来源:io.c

示例7: check

FileRecord *Dir_resolve_file(Dir *dir, bstring path)
{
    FileRecord *file = NULL;
    bstring target = NULL;

    check(Dir_lazy_normalize_base(dir) == 0, "Failed to normalize base path when requesting %s",
            bdata(path));

    check(bstrncmp(path, dir->prefix, blength(dir->prefix)) == 0, 
            "Request for path %s does not start with %s prefix.", 
            bdata(path), bdata(dir->prefix));

    file = FileRecord_cache_check(dir, path);

    if(file) {
        // TODO: double check this gives the right users count
        file->users++;
        return file;
    }

    // We subtract one from the blengths below, because dir->prefix includes
    // a trailing '/'.  If we skip over this in path->data, we drop the '/'
    // from the URI, breaking the target path
    if(bchar(path, blength(path) - 1) == '/') {
        target = bformat("%s%s%s",
                    bdata(dir->normalized_base),
                    path->data + blength(dir->prefix) - 1,
                    bdata(dir->index_file));
    } else {
        target = bformat("%s%s",
                bdata(dir->normalized_base),
                path->data + blength(dir->prefix) - 1);
    }

    check(target, "Couldn't construct target path for %s", bdata(path));

    check_debug(normalize_path(target) == 0, "Failed to normalize target path.");
   
    check_debug(bstrncmp(target, dir->normalized_base, blength(dir->normalized_base)) == 0, 
            "Request for path %s does not start with %s base after normalizing.", 
            bdata(target), bdata(dir->base));

    // the FileRecord now owns the target
    file = Dir_find_file(target, dir->default_ctype);
    check_debug(file, "Error opening file: %s", bdata(target));

    // Increment the user count because we're adding it to the cache
    file->users++;
    file->request_path = bstrcpy(path);
    Cache_add(dir->fr_cache, file);


    return file;

error:
    bdestroy(target);
    FileRecord_release(file);
    return NULL;
}
开发者ID:mattknox,项目名称:Mongrel2,代码行数:59,代码来源:dir.c

示例8: check_debug

char *dl_get_front(list_t *list){
	check_debug(list != NULL, "List is NULL.");
	check_debug(list->next != NULL && list->next != list, 
		"List is empty.");
	check_debug(list->next->word != NULL,
		"list->next->word is NULL.");
	return list->next->word;
error:
	return NULL;
}
开发者ID:quadewarren,项目名称:cs342302,代码行数:10,代码来源:dllist.c

示例9: dl_pop_back

bool dl_pop_back(list_t *list){
	check_debug(list != NULL, "List is NULL.");
	check_debug(list->prev != NULL && list->prev != list,
		"List is empty.");
	check_debug(dl_remove(list, list->prev) == 1, 
		"Delete from back was not successful.");
	return 1;
error:
	return 0;
}
开发者ID:quadewarren,项目名称:cs342302,代码行数:10,代码来源:dllist.c

示例10: dl_pop_front

bool dl_pop_front(list_t *list){
	check_debug(list != NULL, "List is NULL.");
	check_debug(list->next != NULL && list->next != list,
		"List is empty.");
	check_debug(dl_remove(list, list->next) == 1, 
		"Delete from front was not successful.");
	return 1;
error:
	return 0;
}
开发者ID:quadewarren,项目名称:cs342302,代码行数:10,代码来源:dllist.c

示例11: main

int main(int argc, const char *argv[])
{
    fd_set allreads;
    fd_set readmask;

    int socket = 0;
    int rc = 0;
    RingBuffer *in_rb = RingBuffer_create(1024 * 10);
    RingBuffer *sock_rb = RingBuffer_create(1024 * 10);

    check(argc == 3, "USAGE: netclient HOST PORT");

    socket = client_connect(argv[1], argv[2]);
    check(socket >= 0, "Connect to %s:%s failed.", argv[1], argv[2]);

    FD_ZERO(&allreads);
    FD_SET(socket, &allreads);
    FD_SET(0, &allreads);

    while(1) {
        readmask = allreads;
        rc = select(socket + 1, &readmask, NULL, NULL, NULL);
        check(rc >= 0, "Select failed");

        if(FD_ISSET(0, &readmask)) {
            rc = read_some(in_rb, 0, 0);
            check_debug(rc != -1, "failed to read from stdin.");
        }

        if(FD_ISSET(socket, &readmask)) {
            rc = read_some(sock_rb, socket, 0);
            check_debug(rc != -1, "failed to read from socket.");
        }

        while(!RingBuffer_empty(sock_rb)) {
            rc = write_some(sock_rb, 1, 0);
            check_debug(rc != -1, "failed to write to stdout.");
        }

        while(!RingBuffer_empty(in_rb)) {
            rc = write_some(in_rb, socket, 1);
            check_debug(rc != -1, "failed to write to socket.");
        }

    }

    RingBuffer_destroy(in_rb);
    RingBuffer_destroy(sock_rb);

    return 0;

error:
    return -1;
}
开发者ID:bmoar,项目名称:c_skelly,代码行数:54,代码来源:netclient.c

示例12: Connection_deliver_enqueue

static inline int Connection_deliver_enqueue(Connection *conn, bstring b)
{
    check_debug(conn->deliverPost-conn->deliverAck < DELIVER_OUTSTANDING_MSGS, "Too many outstanding messages") ;
    check_debug(conn->deliverTaskStatus==DT_RUNNING, "Cannot enqueue, deliver task not running");
    conn->deliverRing[conn->deliverPost++%DELIVER_OUTSTANDING_MSGS]=b;
    taskwakeup(&conn->deliverRendez);
    return 0;

error:
    return -1;
}
开发者ID:AlexVPopov,项目名称:mongrel2,代码行数:11,代码来源:connection.c

示例13: dl_sort

bool dl_sort(list_t *list){
	check_debug(list != NULL,
		"list is null.");
	check_debug(list->prev != NULL
		&& list->next != NULL
		&& list->prev != list
		&& list->next != list,
		"list is empty.");
	while(bubble_sort(list) != 1){}
	return 1;
error:
	return 0;	
}
开发者ID:quadewarren,项目名称:cs342302,代码行数:13,代码来源:dllist.c

示例14: Register_fd_for_id

int Register_fd_for_id(uint32_t id)
{
    RMElement *el = RadixMap_find(REG_ID_TO_FD, id);

    check_debug(el != NULL, "Id %d not registered.", id);

    Registration *reg = darray_get(REGISTRATIONS, el->data.value);
    check_debug(Register_valid(reg), "Nothing registered under id %d.", id);

    return reg->fd;
error:
    return -1;
}
开发者ID:304471720,项目名称:mongrel2,代码行数:13,代码来源:register.c

示例15: dl_get_wordcount

int dl_get_wordcount(list_t *list, char *word){
	check_debug(list != NULL,
		"list is NULL.");
	check_debug(word != NULL,
		"word is NULL");
	list_t *node = NULL;
	node = dl_check(list, word);
	check_debug(node != NULL,
		"word '%s' not in list.", word);
	return node->word_count;
error:
	return 0;
}
开发者ID:quadewarren,项目名称:cs342302,代码行数:13,代码来源:dllist.c


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