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

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

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

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

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

示例1: test_command_cb

static voidtest_command_cb (DBusGProxy *proxy,		 char *word[],		 char *word_eol[],		 guint hook_id,		 guint context_id,		 gpointer user_data){	GError *error = NULL;	if (hook_id == command_id) {		if (!dbus_g_proxy_call (proxy, "Unhook",					&error,					G_TYPE_UINT, hook_id,					G_TYPE_INVALID, G_TYPE_INVALID)) {			write_error ("Failed to complete unhook", &error);		}		/* Now if you write "/test blah" again in the HexChat window		 * you'll get a "Unknown command" error message */		g_print ("test command received: %s/n", word_eol[1]);		if (!dbus_g_proxy_call (proxy, "Print",					&error,					G_TYPE_STRING, "test command succeed",					G_TYPE_INVALID,					G_TYPE_INVALID)) {			write_error ("Failed to complete Print", &error);		}	}}
开发者ID:94m3k1n9,项目名称:hexchat,代码行数:29,


示例2: net_stream_open

static int net_stream_open(client_t* cl,char* url) {  int file_format=DEMUXER_TYPE_UNKNOWN;  mp_net_stream_opened_t ret;  if(cl->stream) {    if(!write_error(cl->fd,"A stream is currently opened/n"))      return 0;    return 1;  }  mp_msg(MSGT_NETST,MSGL_V,"Open stream %s/n",url);  cl->stream = open_stream(url,NULL,&file_format);  if(!cl->stream) {    if(!write_error(cl->fd,"Open failed/n"))      return 0;    return 1;  }  stream_reset(cl->stream);  stream_seek(cl->stream,cl->stream->start_pos);  ret.file_format = file_format;  ret.flags = cl->stream->flags;  ret.sector_size = cl->stream->sector_size;  ret.start_pos = cl->stream->start_pos;  ret.end_pos = cl->stream->end_pos;  net_stream_opened_2_me(&ret);  if(!write_packet(cl->fd,NET_STREAM_OK,(char*)&ret,sizeof(mp_net_stream_opened_t)))    return 0;  return 1;}
开发者ID:OpenSageTV,项目名称:mplayer-sage9orig,代码行数:30,


示例3: net_stream_fill_buffer

static int net_stream_fill_buffer(client_t* cl,uint16_t max_len) {  int r;  mp_net_stream_packet_t *pack;    if(!cl->stream) {    if(!write_error(cl->fd,"No stream is currently opened/n"))      return 0;    return 1;  }  if(max_len == 0) {    if(!write_error(cl->fd,"Fill buffer called with 0 lenght/n"))      return 0;    return 1;  }  pack = malloc(max_len + sizeof(mp_net_stream_packet_t));  pack->cmd = NET_STREAM_OK;  r = stream_read(cl->stream,pack->data,max_len);  pack->len = le2me_16(r + sizeof(mp_net_stream_packet_t));  if(!net_write(cl->fd,(char*)pack,le2me_16(pack->len))) {    free(pack);    return 0;  }  free(pack);  return 1;}
开发者ID:OpenSageTV,项目名称:mplayer-sage9orig,代码行数:25,


示例4: assimilate_handler

int assimilate_handler(		WORKUNIT& wu,		std::vector<RESULT>& /*results*/,		RESULT& canonical_result) {    int retval;    char buf[1024];    MapReduceTask* mrt = NULL;    // First time initialization (loads jobtracker state).    // This information is loaded into memory but we only need the output paths    // and wu names. We are not updating the file here.    if(jobtracker_file == NULL) {		// Open jobtracker state file.		jobtracker_file = fopen(jobtracker_file_path, "r+");		if (!jobtracker_file){			sprintf(buf, "Can't jobtracker file (%s)./n", jobtracker_file_path);			return write_error(buf);		}		// Parse jobtracker state file.		retval = parse_jobtracker(jobtracker_file, jobs);		if(retval) {			sprintf(buf, "Error parsing jobtracker file/n");			return write_error(buf);		}    }    retval = boinc_mkdir(config.project_path("sample_results"));    if (retval) return retval;    if (wu.canonical_resultid) {        std::vector<OUTPUT_FILE_INFO> output_files;        const char *copy_path;        get_output_file_infos(canonical_result, output_files);        bool file_copied = false;        // Get the task identified by the work unit name.        mrt = get_task_by_name(jobs, wu.name);        if (mrt == NULL) {			sprintf(buf, "Can't find MapRedureTask %s/n", wu.name);			return write_error(buf);        }		// FIXME - if wu.name contains reduce, also copy to bt new. -> put mrt output task = bt new		retval = boinc_copy(output_files[0].path.c_str() , mrt->getOutputPath().c_str());		if (!retval) { file_copied = true; }        if (!file_copied) {            copy_path = config.project_path("sample_results/%s_%s", wu.name, "no_output_files");            FILE* f = fopen(copy_path, "w");            fclose(f);        }    } else {        sprintf(buf, "%s: 0x%x/n", wu.name, wu.error_mask);        return write_error(buf);    }    return 0;}
开发者ID:rodrigo-bruno,项目名称:freeCycles,代码行数:57,


示例5: main

int main(int argc, char **argv) {	const int wfilter = WFILTER;	const int hfilter = HFILTER;	const int wimage = WIMAGE;	const int himage = HIMAGE;	char* filename = TEST_FILENAME;	/* allocate memory space for two input matrices and the result matrix. */	uint64_t* newimg = calloc(wimage*himage, sizeof(uint64_t));	uint16_t* filter = calloc(wfilter*hfilter, sizeof(uint16_t));	uint16_t* image = calloc(wimage*himage+2*PAD_ZERO, sizeof(uint16_t));	image += PAD_ZERO;	srand(time(0));	for (int i = 0; i < wfilter*hfilter; i++) {		filter[i] = rand()%32767;	}	for (int i = 0; i < wimage*himage; i++) {		image[i] = rand()%32767;	}	/* calculate the result matrix */	for (int i = 0; i < wimage; i++)	{		for (int m = 0; m < wfilter; m++)		{            for (int n = 0; n < hfilter; n++)            {                uint64_t scalarF = filter[m*WFILTER+n];                for (int j = 0; j < himage; j++)                {                    newimg[i*WIMAGE+j] += scalarF*image[OFFSET+(i-m)*WIMAGE+(j-n)];                }            }		}	}	FILE* file = fopen(filename, "wb");	if (!file) write_error();	if (!fwrite(&wfilter, sizeof(int), 1, file)) write_error();	if (!fwrite(&hfilter, sizeof(int), 1, file)) write_error();	if (!fwrite(&wimage, sizeof(int), 1, file)) write_error();	if (!fwrite(&himage, sizeof(int), 1, file)) write_error();	if (fwrite(newimg, sizeof(uint64_t), wimage*himage, file)<wimage*himage) write_error();	if (fwrite(filter, sizeof(uint16_t), wfilter*hfilter, file)<wfilter*hfilter) write_error();	if (fwrite(image, sizeof(uint16_t), wimage*himage, file)<wimage*himage) write_error();	if (fclose(file)) write_error();	free(image-PAD_ZERO);	free(filter);	free(newimg);	return EXIT_SUCCESS;}
开发者ID:Hurricane-Jason-Harry,项目名称:ConvolutionOptimization,代码行数:55,


示例6: while

static struct iflist *positionptr(struct iflist *iflist, const int ifindex){	struct iflist *ptmp = iflist;	struct iflist *last = ptmp;	while ((ptmp != NULL) && (ptmp->ifindex != ifindex)) {		last = ptmp;		ptmp = ptmp->next_entry;	}	/* no interface was found, try to create new one */	if (ptmp == NULL) {		struct iflist *itmp = xmallocz(sizeof(struct iflist));		itmp->ifindex = ifindex;		itmp->index = last->index + 1;		int r = dev_get_ifname(ifindex, itmp->ifname);		if (r != 0) {			write_error("Error getting interface name");			return(NULL);		}		/* last can't be NULL otherwise we will have empty iflist */		last->next_entry = itmp;		itmp->prev_entry = last;		itmp->next_entry = NULL;		ptmp = itmp;	}	return(ptmp);}
开发者ID:ebichu,项目名称:dd-wrt,代码行数:28,


示例7: copyfiles_by_name

/*      Copy srcFile to destFile  */int copyfiles_by_name(char *srcFile, char *destFile){    FILE *f, *g;    int status = 0;    long fileLength;    f = fopen(srcFile, FOPRBIN);    if (f == NULL)	return -1;    g = fopen(destFile, FOPWBIN);    if (g == NULL) {	fclose(f);	return -1;    }    /* Get file length and copy it */    fseek(f, 0L, SEEK_END);    fileLength = ftell(f);    rewind(f);    status = copyfile(f, g, fileLength);    fclose(f);    if (write_error(g))	status = -1;    fclose(g);    return status;}				/* copyfiles_by_name */
开发者ID:BoxianLai,项目名称:moxiedev,代码行数:26,


示例8: write_directory_file

voidwrite_directory_file (void){  FILE *fp = listed_incremental_stream;  char buf[UINTMAX_STRSIZE_BOUND];  char *s;  if (! fp)    return;  if (fseeko (fp, 0L, SEEK_SET) != 0)    seek_error (listed_incremental_option);  if (sys_truncate (fileno (fp)) != 0)    truncate_error (listed_incremental_option);  fprintf (fp, "%s-%s-%d/n", PACKAGE_NAME, PACKAGE_VERSION,	   TAR_INCREMENTAL_VERSION);  s = (TYPE_SIGNED (time_t)       ? imaxtostr (start_time.tv_sec, buf)       : umaxtostr (start_time.tv_sec, buf));  fwrite (s, strlen (s) + 1, 1, fp);  s = umaxtostr (start_time.tv_nsec, buf);  fwrite (s, strlen (s) + 1, 1, fp);  if (! ferror (fp) && directory_table)    hash_do_for_each (directory_table, write_directory_file_entry, fp);  if (ferror (fp))    write_error (listed_incremental_option);  if (fclose (fp) != 0)    close_error (listed_incremental_option);}
开发者ID:jelaas,项目名称:bifrost-build,代码行数:33,


示例9: fork_this

int				fork_this(char *full_path, char **arg, char **env){    int			status;    int			ch_pid;    int			w;    int			ret;    init(&ret, &ch_pid, &status);    static_fork(full_path, &ch_pid);    if (ch_pid > 0)    {        if ((w = waitpid(ch_pid, &status, 0)) == -1)            perror_wpid();    }    else if (!ch_pid && full_path)    {        ret = execve(full_path, arg, env);        if (ret == -1)        {            write_error(&full_path);            ft_putendl_fd(full_path, 2);        }        exit(ret);    }    return (status);}
开发者ID:v3t3a,项目名称:42_projects,代码行数:26,


示例10: mbox_append_lf

static int mbox_append_lf(struct mbox_save_context *ctx){	if (o_stream_send(ctx->output, "/n", 1) < 0)		return write_error(ctx);	return 0;}
开发者ID:via,项目名称:dovecot-clouddb,代码行数:7,


示例11: xmlTextWriterWriteFormatAttribute

void xml_writer::attribute(const std::string &name, int value) {  int rc = xmlTextWriterWriteFormatAttribute(      pimpl->writer, BAD_CAST name.c_str(), "%d", value);  if (rc < 0) {    throw write_error("cannot write integer attribute.");  }}
开发者ID:dgreyling,项目名称:cgimap,代码行数:7,


示例12: readPhantomInput

/* read the data from stdin to the phantom input file */int readPhantomInput(char *filename){    FILE *outFilePtr;    byte buffer[512];    int bytesRead, status = 0;    if (verbose)	fprintf(pgpout, "writing stdin to file %s/n", filename);    if ((outFilePtr = fopen(filename, FOPWBIN)) == NULL)	return -1;#if defined(MSDOS) || defined(OS2) || defined (WIN32)    /* Under DOS must set input stream to binary mode to avoid data mangling */    setmode(fileno(stdin), O_BINARY);#endif				/* MSDOS || OS2 */    while ((bytesRead = fread(buffer, 1, 512, stdin)) > 0)	if (fwrite(buffer, 1, bytesRead, outFilePtr) != bytesRead) {	    status = -1;	    break;	}    if (write_error(outFilePtr))	status = -1;    fclose(outFilePtr);#if defined(MSDOS) || defined(OS2) || defined (WIN32)    setmode(fileno(stdin), O_TEXT);	/* Reset stream */#endif				/* MSDOS || OS2 */    return status;}
开发者ID:BoxianLai,项目名称:moxiedev,代码行数:29,


示例13: process_connection

static void* process_connection(void *arg) {	struct pollfd fds[2];	char buf[BUF_SIZE];	int i = CLIENT, res;	init_sock(fds[CLIENT].fd = (long) arg);	fds[CLIENT].events = POLLIN | POLLERR | POLLHUP;	fds[SERVER].fd = -1;	fds[SERVER].events = POLLIN | POLLERR | POLLHUP;	fds[SERVER].fd = res = prepare_http(fds[CLIENT].fd, buf);	while (res >= 0) {		i = SERVER;		if (!(res = poll(fds, 2, inactivity_timeout * 1000)))			break;		for (i = 0; res > 0 && i < 2; ++i)			if ((fds[i].revents & POLL_IN))				res = send_data(buf, i, fds + i, fds[i ^ 1].fd);			else if ((fds[i].revents & (POLLERR | POLLHUP)))				res = ERR_IO;	}	if (res < 0 && (i == SERVER || res != ERR_IO))		write_error(buf, fds[CLIENT].fd, res);	if (fds[SERVER].fd >= 0)		close(fds[SERVER].fd);	close(fds[CLIENT].fd);	return NULL;}
开发者ID:mth,项目名称:noxref,代码行数:27,


示例14: write_from_line

static int write_from_line(struct mbox_save_context *ctx, time_t received_date,			   const char *from_envelope){	int ret;	T_BEGIN {		const char *line;		if (from_envelope == NULL) {			struct mail_storage *storage =				&ctx->mbox->storage->storage;			from_envelope =				strchr(storage->user->username, '@') != NULL ?				storage->user->username :				t_strconcat(storage->user->username,					    "@", my_hostdomain(), NULL);		} else if (*from_envelope == '/0') {			/* can't write empty envelope */			from_envelope = "MAILER-DAEMON";		}		/* save in local timezone, no matter what it was given with */		line = mbox_from_create(from_envelope, received_date);		if ((ret = o_stream_send_str(ctx->output, line)) < 0)			write_error(ctx);	} T_END;	return ret;}
开发者ID:via,项目名称:dovecot-clouddb,代码行数:30,


示例15: mbox_seek_to_end

static int mbox_seek_to_end(struct mbox_save_context *ctx, uoff_t *offset){	struct stat st;	char ch;	int fd;	if (ctx->mbox->mbox_writeonly) {		*offset = 0;		return 0;	}	fd = ctx->mbox->mbox_fd;	if (fstat(fd, &st) < 0)                return mbox_set_syscall_error(ctx->mbox, "fstat()");	ctx->orig_atime = st.st_atime;	*offset = (uoff_t)st.st_size;	if (st.st_size == 0)		return 0;	if (lseek(fd, st.st_size-1, SEEK_SET) < 0)                return mbox_set_syscall_error(ctx->mbox, "lseek()");	if (read(fd, &ch, 1) != 1)		return mbox_set_syscall_error(ctx->mbox, "read()");	if (ch != '/n') {		if (write_full(fd, "/n", 1) < 0)			return write_error(ctx);		*offset += 1;	}	return 0;}
开发者ID:via,项目名称:dovecot-clouddb,代码行数:35,


示例16: xmlTextWriterWriteAttribute

void xml_writer::attribute(const std::string &name, const std::string &value) {  int rc = xmlTextWriterWriteAttribute(pimpl->writer, BAD_CAST name.c_str(),                                       BAD_CAST value.c_str());  if (rc < 0) {    throw write_error("cannot write attribute.");  }}
开发者ID:dgreyling,项目名称:cgimap,代码行数:7,


示例17: net_stream_seek

static int net_stream_seek(client_t* cl, uint64_t pos) {    if(!cl->stream) {    if(!write_error(cl->fd,"No stream is currently opened/n"))      return 0;    return 1;  }  if(!stream_seek(cl->stream,(off_t)pos)) {    if(!write_error(cl->fd,"Seek failed/n"))      return 0;    return 1;  }  if(!write_packet(cl->fd,NET_STREAM_OK,NULL,0))    return 0;  return 1;}
开发者ID:OpenSageTV,项目名称:mplayer-sage9orig,代码行数:17,


示例18: if

void Option<bool>::set_from_string(const char* value) {    if (strcmp(value, "true") == 0 || strcmp(value, "1") == 0)        _value = true;    else if (strcmp(value, "false") == 0 || strcmp(value, "0") == 0)        _value = false;    else        write_error("error converting string '%s' to bool", value);}
开发者ID:github188,项目名称:hackacam_sdk,代码行数:8,


示例19: write_error

const char* OptionSet::type_name(OptionBase* option) {    if (dynamic_cast< Option<int>*    >(option))   return "int";    if (dynamic_cast< Option<double>* >(option))   return "double";    if (dynamic_cast< Option<bool>*   >(option))   return "bool";    if (dynamic_cast< Option<String>* >(option))   return "string";    write_error("unknown option type for option '%s'", option->name());    return 0;}
开发者ID:github188,项目名称:hackacam_sdk,代码行数:8,


示例20: child

int	child(t_data *data){  int	i;  i = -1;  if ((access(data->args[0], X_OK)) == 0)    execve(data->args[0], data->args, data->envcpy);  if (data->path == NULL || data->path[0] == NULL)    write_error(data);  while (data->path[++i] != NULL && access(data->path[i], X_OK) == -1)    if (data->path[i + 1] == NULL)      write_error(data);  if (execve(data->path[i], data->args, data->envcpy) == -1 &&      data->args[0][0] != 32)    return (-1);  return (0);}
开发者ID:peauc,项目名称:minishell1,代码行数:17,


示例21: loadfilter

int loadfilter(char *filename, struct filterlist *fl, int resolve){	struct filterent *fe;	int pfd;	unsigned int idx = 0;	int br;	int resolv_err = 0;	init_filter_table(fl);	pfd = open(filename, O_RDONLY);	if (pfd < 0) {		write_error("Error opening IP filter data file");		fl->head = NULL;		return 1;	}	do {		fe = xmalloc(sizeof(struct filterent));		br = read(pfd, &(fe->hp), sizeof(struct hostparams));		if (br > 0) {			fe->index = idx;			if (resolve) {				fe->saddr =				    nametoaddr(fe->hp.s_fqdn, &resolv_err);				fe->daddr =				    nametoaddr(fe->hp.d_fqdn, &resolv_err);				if (resolv_err) {					free(fe);					continue;				}				fe->smask = inet_addr(fe->hp.s_mask);				fe->dmask = inet_addr(fe->hp.d_mask);			}			if (fl->head == NULL) {				fl->head = fe;				fe->prev_entry = NULL;			} else {				fl->tail->next_entry = fe;				fe->prev_entry = fl->tail;			}			fe->next_entry = NULL;			fl->tail = fe;			idx++;		} else {			free(fe);		}	} while (br > 0);	if (br == 0)		close(pfd);	return 0;}
开发者ID:josarlo84,项目名称:iptraf,代码行数:57,


示例22: write_response

int write_response(http_method method, char *url, char *protocol) {    /* check for HTTP 1.0 protocol */    if (strcmp(protocol, PROTOCOL) != 0) {        return write_error(STATUS_HTTP_VERSION_NOT_SUPPORTED);    }    /* add a handle_* procedure for each HTTP method */    switch (method) {        case METHOD_GET:            return handle_get(url);            break;        default:            /* unsupported method */            return write_error(STATUS_NOT_IMPLEMENTED);    }}
开发者ID:TrainingProject,项目名称:tcp,代码行数:18,


示例23: open_socket

void open_socket(int *fd){    *fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));    if (*fd < 0) {        write_error("Unable to open raw socket", daemonized);        return;    }}
开发者ID:hobinyoon,项目名称:iptraf-3.0.0,代码行数:9,


示例24: mbox_write_content_length

static int mbox_write_content_length(struct mbox_save_context *ctx){	uoff_t end_offset;	const char *str;	size_t len;	i_assert(ctx->eoh_offset != (uoff_t)-1);	if (ctx->mbox->mbox_writeonly) {		/* we can't seek, don't set Content-Length */		return 0;	}	end_offset = ctx->output->offset;	/* write Content-Length headers */	str = t_strdup_printf("/nContent-Length: %s",			      dec2str(end_offset - ctx->eoh_offset));	len = strlen(str);	/* flush manually here so that we don't confuse seek() errors with	   buffer flushing errors */	if (o_stream_flush(ctx->output) < 0) {		write_error(ctx);		return -1;	}	if (o_stream_seek(ctx->output, ctx->extra_hdr_offset +			  ctx->space_end_idx - len) < 0) {		mbox_set_syscall_error(ctx->mbox, "lseek()");		return -1;	}	if (o_stream_send(ctx->output, str, len) < 0 ||	    o_stream_flush(ctx->output) < 0) {		write_error(ctx);		return -1;	}	if (o_stream_seek(ctx->output, end_offset) < 0) {		mbox_set_syscall_error(ctx->mbox, "lseek()");		return -1;	}	return 0;}
开发者ID:Distrotech,项目名称:dovecot,代码行数:44,


示例25: main

int main(int argc,char **argv) {		char* errmsg;	printf("%d/n", write_error(3,"prueba>","pruebaz>",33,&errmsg));		printf("%s/n",errmsg);			return 0;}
开发者ID:jorgeCollinet,项目名称:orgadecomputadoras-tp-2014,代码行数:10,


示例26: xmlTextWriterSetIndent

void xml_writer::init(bool indent) {  // maybe enable indenting  if (indent) {    xmlTextWriterSetIndent(pimpl->writer, 1);  }  // start the document  if (xmlTextWriterStartDocument(pimpl->writer, NULL, "UTF-8", NULL) < 0) {    throw write_error("error creating document element.");  }}
开发者ID:dgreyling,项目名称:cgimap,代码行数:11,



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


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