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

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

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

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

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

示例1: Mmsg0

/* * Set the position of the device -- only for files and DVD *   For other devices, there is no generic way to do it. *  Returns: true  on succes *           false on error */bool DEVICE::update_pos(DCR *dcr){   boffset_t pos;   bool ok = true;   if (!is_open()) {      dev_errno = EBADF;      Mmsg0(errmsg, _("Bad device call. Device not open/n"));      Emsg1(M_FATAL, 0, "%s", errmsg);      return false;   }   if (is_file()) {      file = 0;      file_addr = 0;      pos = lseek(dcr, (boffset_t)0, SEEK_CUR);      if (pos < 0) {         berrno be;         dev_errno = errno;         Pmsg1(000, _("Seek error: ERR=%s/n"), be.bstrerror());         Mmsg2(errmsg, _("lseek error on %s. ERR=%s./n"),               print_name(), be.bstrerror());         ok = false;      } else {         file_addr = pos;         block_num = (uint32_t)pos;         file = (uint32_t)(pos >> 32);      }   }   return ok;}
开发者ID:prelegalwonder,项目名称:bacula,代码行数:37,


示例2: Emsg2

POOLMEM *sm_get_pool_memory(const char *fname, int lineno, int pool){   struct abufhead *buf;   if (pool > PM_MAX) {      Emsg2(M_ABORT, 0, _("MemPool index %d larger than max %d/n"), pool, PM_MAX);   }   P(mutex);   if (pool_ctl[pool].free_buf) {      buf = pool_ctl[pool].free_buf;      pool_ctl[pool].free_buf = buf->next;      pool_ctl[pool].in_use++;      if (pool_ctl[pool].in_use > pool_ctl[pool].max_used) {         pool_ctl[pool].max_used = pool_ctl[pool].in_use;      }      V(mutex);      Dmsg3(dbglvl, "sm_get_pool_memory reuse %p to %s:%d/n", buf, fname, lineno);      sm_new_owner(fname, lineno, (char *)buf);      return (POOLMEM *)((char *)buf+HEAD_SIZE);   }   if ((buf = (struct abufhead *)sm_malloc(fname, lineno, pool_ctl[pool].size+HEAD_SIZE)) == NULL) {      V(mutex);      Emsg1(M_ABORT, 0, _("Out of memory requesting %d bytes/n"), pool_ctl[pool].size);   }   buf->ablen = pool_ctl[pool].size;   buf->pool = pool;   pool_ctl[pool].in_use++;   if (pool_ctl[pool].in_use > pool_ctl[pool].max_used) {      pool_ctl[pool].max_used = pool_ctl[pool].in_use;   }   V(mutex);   Dmsg3(dbglvl, "sm_get_pool_memory give %p to %s:%d/n", buf, fname, lineno);   return (POOLMEM *)((char *)buf+HEAD_SIZE);}
开发者ID:rkorzeniewski,项目名称:bacula,代码行数:35,


示例3: P

POOLMEM *get_pool_memory(int pool){   struct abufhead *buf;   P(mutex);   if (pool_ctl[pool].free_buf) {      buf = pool_ctl[pool].free_buf;      pool_ctl[pool].free_buf = buf->next;      V(mutex);      return (POOLMEM *)((char *)buf+HEAD_SIZE);   }   if ((buf=malloc(pool_ctl[pool].size+HEAD_SIZE)) == NULL) {      V(mutex);      Emsg1(M_ABORT, 0, _("Out of memory requesting %d bytes/n"), pool_ctl[pool].size);   }   buf->ablen = pool_ctl[pool].size;   buf->pool = pool;   buf->next = NULL;   pool_ctl[pool].in_use++;   if (pool_ctl[pool].in_use > pool_ctl[pool].max_used) {      pool_ctl[pool].max_used = pool_ctl[pool].in_use;   }   V(mutex);   return (POOLMEM *)(((char *)buf)+HEAD_SIZE);}
开发者ID:rkorzeniewski,项目名称:bacula,代码行数:26,


示例4: cleanup_bnet_thread_server

/* * Perform a cleanup for the Threaded Network Server check if there is still * something to do or that the cleanup already took place. */void cleanup_bnet_thread_server(alist *sockfds, workq_t *client_wq){   int status;   s_sockfd *fd_ptr = NULL;   if (!sockfds->empty()) {      /*       * Cleanup open files and pointers to them       */      fd_ptr = (s_sockfd *)sockfds->first();      while (fd_ptr) {         close(fd_ptr->fd);         fd_ptr = (s_sockfd *)sockfds->next();      }      sockfds->destroy();      /*       * Stop work queue thread       */      if ((status = workq_destroy(client_wq)) != 0) {         berrno be;         be.set_errno(status);         Emsg1(M_FATAL, 0, _("Could not destroy client queue: ERR=%s/n"),               be.bstrerror());      }   }}
开发者ID:eneuhauss,项目名称:bareos,代码行数:32,


示例5: object_store_logfunc

/* * Generic log function that glues libdroplet with BAREOS. */static void object_store_logfunc(dpl_ctx_t *ctx, dpl_log_level_t level, const char *message){   switch (level) {   case DPL_DEBUG:      Dmsg1(100, "%s/n", message);      break;   case DPL_INFO:      Emsg1(M_INFO, 0, "%s/n", message);      break;   case DPL_WARNING:      Emsg1(M_WARNING, 0, "%s/n", message);      break;   case DPL_ERROR:      Emsg1(M_ERROR, 0, "%s/n", message);      break;   }}
开发者ID:aussendorf,项目名称:bareos,代码行数:20,


示例6: init_vol_list_lock

/* *  Initialized the main volume list. Note, we are using a recursive lock. */void init_vol_list_lock(){   int errstat;   if ((errstat=rwl_init(&vol_list_lock, PRIO_SD_VOL_LIST)) != 0) {      berrno be;      Emsg1(M_ABORT, 0, _("Unable to initialize volume list lock. ERR=%s/n"),            be.bstrerror(errstat));   }}
开发者ID:eneuhauss,项目名称:bareos,代码行数:12,


示例7: do_extract

static void do_extract(char *devname){   struct stat statp;   enable_backup_privileges(NULL, 1);   jcr = setup_jcr("bextract", devname, bsr, director, VolumeName, 1); /* acquire for read */   if (!jcr) {      exit(1);   }   dev = jcr->read_dcr->dev;   if (!dev) {      exit(1);   }   dcr = jcr->read_dcr;   /* Make sure where directory exists and that it is a directory */   if (stat(where, &statp) < 0) {      berrno be;      Emsg2(M_ERROR_TERM, 0, _("Cannot stat %s. It must exist. ERR=%s/n"),         where, be.bstrerror());   }   if (!S_ISDIR(statp.st_mode)) {      Emsg1(M_ERROR_TERM, 0, _("%s must be a directory./n"), where);   }   free(jcr->where);   jcr->where = bstrdup(where);   attr = new_attr(jcr);   compress_buf = get_memory(compress_buf_size);   acl_data.last_fname = get_pool_memory(PM_FNAME);   xattr_data.last_fname = get_pool_memory(PM_FNAME);   read_records(dcr, record_cb, mount_next_read_volume);   /* If output file is still open, it was the last one in the    * archive since we just hit an end of file, so close the file.    */   if (is_bopen(&bfd)) {      set_attributes(jcr, attr, &bfd);   }   free_attr(attr);   free_pool_memory(acl_data.last_fname);   free_pool_memory(xattr_data.last_fname);   clean_device(jcr->dcr);   dev->term();   free_dcr(dcr);   free_jcr(jcr);   printf(_("%u files restored./n"), num_files);   return;}
开发者ID:eneuhauss,项目名称:bareos,代码行数:55,


示例8: calloc

void *bcalloc(size_t size1, size_t size2){  void *buf;   buf = calloc(size1, size2);   if (buf == NULL) {      berrno be;      Emsg1(M_ABORT, 0, _("Out of memory: ERR=%s/n"), be.bstrerror());   }   return buf;}
开发者ID:pstray,项目名称:bareos,代码行数:11,


示例9: start_UA_server

/* Called here by Director daemon to start UA (user agent) * command thread. This routine creates the thread and then * returns. */void start_UA_server(dlist *addrs){   int status;   static dlist *myaddrs = addrs;   if ((status = pthread_create(&tcp_server_tid, NULL, connect_thread, (void *)myaddrs)) != 0) {      berrno be;      Emsg1(M_ABORT, 0, _("Cannot create UA thread: %s/n"), be.bstrerror(status));   }   started = TRUE;   return;}
开发者ID:aAnsgarWuestenhagen,项目名称:bareos,代码行数:17,


示例10: sm_realloc

void *brealloc (void *buf, size_t size){#ifdef SMARTALOC   buf = sm_realloc(__FILE__, __LINE__, buf, size);#else   buf = realloc(buf, size);#endif   if (buf == NULL) {      berrno be;      Emsg1(M_ABORT, 0, _("Out of memory: ERR=%s/n"), be.bstrerror());   }   return buf;}
开发者ID:pstray,项目名称:bareos,代码行数:13,


示例11: sm_malloc

void *bmalloc(size_t size){  void *buf;#ifdef SMARTALLOC  buf = sm_malloc(file, line, size);#else  buf = malloc(size);#endif  if (buf == NULL) {     berrno be;     Emsg1(M_ABORT, 0, _("Out of memory: ERR=%s/n"), be.bstrerror());  }  return buf;}
开发者ID:pstray,项目名称:bareos,代码行数:15,


示例12: Emsg1

/* Get nonpool memory of size requested */POOLMEM *sm_get_memory(const char *fname, int lineno, int32_t size){   struct abufhead *buf;   int pool = 0;   if ((buf = (struct abufhead *)sm_malloc(fname, lineno, size+HEAD_SIZE)) == NULL) {      Emsg1(M_ABORT, 0, _("Out of memory requesting %d bytes/n"), size);   }   buf->ablen = size;   buf->pool = pool;   buf->next = NULL;   pool_ctl[pool].in_use++;   if (pool_ctl[pool].in_use > pool_ctl[pool].max_used)      pool_ctl[pool].max_used = pool_ctl[pool].in_use;   return (POOLMEM *)(((char *)buf)+HEAD_SIZE);}
开发者ID:rkorzeniewski,项目名称:bacula,代码行数:17,


示例13: init_job_server

void init_job_server(int max_workers){   int status;   watchdog_t *wd;   if ((status = jobq_init(&job_queue, max_workers, job_thread)) != 0) {      berrno be;      Emsg1(M_ABORT, 0, _("Could not init job queue: ERR=%s/n"), be.bstrerror(status));   }   wd = new_watchdog();   wd->callback = job_monitor_watchdog;   wd->destructor = job_monitor_destructor;   wd->one_shot = false;   wd->interval = 60;   wd->data = new_control_jcr("*JobMonitor*", JT_SYSTEM);   register_watchdog(wd);}
开发者ID:eneuhauss,项目名称:bareos,代码行数:17,


示例14: lex_get_token

static BSR *store_slot(LEX *lc, BSR *bsr){   int token;   token = lex_get_token(lc, T_PINT32);   if (token == T_ERROR) {      return NULL;   }   if (!bsr->volume) {      Emsg1(M_ERROR,0, _("Slot %d in bsr at inappropriate place./n"),         lc->pint32_val);      return bsr;   }   bsr->volume->Slot = lc->pint32_val;   scan_to_eol(lc);   return bsr;}
开发者ID:AlD,项目名称:bareos,代码行数:17,


示例15: Emsg1

/* * Connection request. We accept connections either from the * Director, Storage Daemon or a Client (File daemon). * * Note, we are running as a seperate thread of the Storage daemon. * * Basic tasks done here: *  - If it was a connection from the FD, call handle_filed_connection() *  - If it was a connection from another SD, call handle_stored_connection() *  - Otherwise it was a connection from the DIR, call handle_director_connection() */static void *handle_connection_request(void *arg){   BSOCK *bs = (BSOCK *)arg;   char name[MAX_NAME_LENGTH];   char tbuf[MAX_TIME_LENGTH];   if (bs->recv() <= 0) {      Emsg1(M_ERROR, 0, _("Connection request from %s failed./n"), bs->who());      bmicrosleep(5, 0);   /* make user wait 5 seconds */      bs->close();      return NULL;   }   /*    * Do a sanity check on the message received    */   if (bs->msglen < MIN_MSG_LEN || bs->msglen > MAX_MSG_LEN) {      Dmsg1(000, "<filed: %s", bs->msg);      Emsg2(M_ERROR, 0, _("Invalid connection from %s. Len=%d/n"), bs->who(), bs->msglen);      bmicrosleep(5, 0);   /* make user wait 5 seconds */      bs->close();      return NULL;   }   Dmsg1(110, "Conn: %s", bs->msg);   /*    * See if this is a File daemon connection. If so call FD handler.    */   if (sscanf(bs->msg, "Hello Start Job %127s", name) == 1) {      Dmsg1(110, "Got a FD connection at %s/n", bstrftimes(tbuf, sizeof(tbuf), (utime_t)time(NULL)));      return handle_filed_connection(bs, name);   }   /*    * See if this is a Storage daemon connection. If so call SD handler.    */   if (sscanf(bs->msg, "Hello Start Storage Job %127s", name) == 1) {      Dmsg1(110, "Got a SD connection at %s/n", bstrftimes(tbuf, sizeof(tbuf), (utime_t)time(NULL)));      return handle_stored_connection(bs, name);   }   Dmsg1(110, "Got a DIR connection at %s/n", bstrftimes(tbuf, sizeof(tbuf), (utime_t)time(NULL)));   return handle_director_connection(bs);}
开发者ID:dl5rcw,项目名称:bareos,代码行数:57,


示例16: Dmsg0

/********************************************************************* * *         Main Bareos Scheduler * */JCR *wait_for_next_job(char *one_shot_job_to_run){   JCR *jcr;   JOBRES *job;   RUNRES *run;   time_t now, prev;   static bool first = true;   job_item *next_job = NULL;   Dmsg0(dbglvl, "Enter wait_for_next_job/n");   if (first) {      first = false;      /* Create scheduled jobs list */      jobs_to_run = New(dlist(next_job, &next_job->link));      if (one_shot_job_to_run) {            /* one shot */         job = (JOBRES *)GetResWithName(R_JOB, one_shot_job_to_run);         if (!job) {            Emsg1(M_ABORT, 0, _("Job %s not found/n"), one_shot_job_to_run);         }         Dmsg1(5, "Found one_shot_job_to_run %s/n", one_shot_job_to_run);         jcr = new_jcr(sizeof(JCR), dird_free_jcr);         set_jcr_defaults(jcr, job);         return jcr;      }   }   /* Wait until we have something in the    * next hour or so.    */again:   while (jobs_to_run->empty()) {      find_runs();      if (!jobs_to_run->empty()) {         break;      }      bmicrosleep(next_check_secs, 0); /* recheck once per minute */   }#ifdef  list_chain   job_item *je;   foreach_dlist(je, jobs_to_run) {      dump_job(je, _("Walk queue"));   }
开发者ID:NilByMouth,项目名称:bareos,代码行数:48,


示例17: memset

static void *do_batch(void *jcr){   JCR *bjcr = (JCR *)jcr;   char data[1024];   int lineno = 0;   struct ATTR_DBR ar;   memset(&ar, 0, sizeof(ar));   btime_t begin = get_current_btime();   char *datafile = bjcr->where;   FILE *fd = fopen(datafile, "r");   if (!fd) {      Emsg1(M_ERROR_TERM, 0, _("Error opening datafile %s/n"), datafile);   }   while (fgets(data, sizeof(data)-1, fd)) {      strip_trailing_newline(data);      lineno++;      if (verbose && ((lineno % 5000) == 1)) {         printf("/r%i", lineno);      }      fill_attr(&ar, data);      if (!db_create_attributes_record(bjcr, bjcr->db, &ar)) {         Emsg0(M_ERROR_TERM, 0, _("Error while inserting file/n"));      }   }   fclose(fd);   db_write_batch_file_records(bjcr);   btime_t end = get_current_btime();   P(mutex);   char ed1[200], ed2[200];   printf("/rbegin = %s, end = %s/n", edit_int64(begin, ed1),edit_int64(end, ed2));   printf("Insert time = %sms/n", edit_int64((end - begin) / 10000, ed1));   printf("Create %u files at %.2f/s/n", lineno,          (lineno / ((float)((end - begin) / 1000000))));   nb--;   V(mutex);   pthread_exit(NULL);   return NULL;}
开发者ID:eneuhauss,项目名称:bareos,代码行数:40,


示例18: ASSERT

/* Realloc pool memory buffer */POOLMEM *realloc_pool_memory(POOLMEM *obuf, int32_t size){   char *cp = (char *)obuf;   void *buf;   int pool;   ASSERT(obuf);   P(mutex);   cp -= HEAD_SIZE;   buf = realloc(cp, size+HEAD_SIZE);   if (buf == NULL) {      V(mutex);      Emsg1(M_ABORT, 0, _("Out of memory requesting %d bytes/n"), size);   }   ((struct abufhead *)buf)->ablen = size;   pool = ((struct abufhead *)buf)->pool;   if (size > pool_ctl[pool].max_allocated) {      pool_ctl[pool].max_allocated = size;   }   V(mutex);   return (POOLMEM *)(((char *)buf)+HEAD_SIZE);}
开发者ID:rkorzeniewski,项目名称:bacula,代码行数:23,


示例19: init_resource

/* * Initialize the static structure to zeros, then *  apply all the default values. */static void init_resource(CONFIG *config, int type, RES_ITEM *items, int pass){   int i;   int rindex = type - r_first;   memset(config->m_res_all, 0, config->m_res_all_size);   res_all.hdr.rcode = type;   res_all.hdr.refcnt = 1;   /* Set defaults in each item */   for (i=0; items[i].name; i++) {      Dmsg3(900, "Item=%s def=%s defval=%d/n", items[i].name,            (items[i].flags & ITEM_DEFAULT) ? "yes" : "no",            items[i].default_value);      if (items[i].flags & ITEM_DEFAULT && items[i].default_value != 0) {         if (items[i].handler == store_bit) {            *(uint32_t *)(items[i].value) |= items[i].code;         } else if (items[i].handler == store_bool) {            *(bool *)(items[i].value) = items[i].default_value != 0;         } else if (items[i].handler == store_pint32 ||                    items[i].handler == store_int32) {            *(uint32_t *)(items[i].value) = items[i].default_value;         } else if (items[i].handler == store_int64) {            *(int64_t *)(items[i].value) = items[i].default_value;         } else if (items[i].handler == store_size) {            *(uint64_t *)(items[i].value) = (uint64_t)items[i].default_value;         } else if (items[i].handler == store_time) {            *(utime_t *)(items[i].value) = (utime_t)items[i].default_value;         } else if (pass == 1 && items[i].handler == store_addresses) {            init_default_addresses((dlist**)items[i].value, items[i].default_value);         }      }      /* If this triggers, take a look at lib/parse_conf.h */      if (i >= MAX_RES_ITEMS) {         Emsg1(M_ERROR_TERM, 0, _("Too many items in %s resource/n"), resources[rindex]);      }   }}
开发者ID:halgandd,项目名称:bacula,代码行数:42,


示例20: bnet_thread_server

/* * Become Threaded Network Server * * This function is able to handle multiple server ips in * ipv4 and ipv6 style. The Addresse are give in a comma * seperated string in bind_addr * * At the moment it is impossible to bind to different ports. */void bnet_thread_server(dlist *addr_list, int max_clients, alist *sockfds,                        workq_t *client_wq, void *handle_client_request(void *bsock)){   int newsockfd, status;   socklen_t clilen;   struct sockaddr cli_addr;       /* client's address */   int tlog, tmax;   int turnon = 1;#ifdef HAVE_LIBWRAP   struct request_info request;#endif   IPADDR *ipaddr, *next;   s_sockfd *fd_ptr = NULL;   char buf[128];#ifdef HAVE_POLL   nfds_t nfds;   struct pollfd *pfds;#endif   char allbuf[256 * 10];   /*    * Remove any duplicate addresses.    */   for (ipaddr = (IPADDR *)addr_list->first(); ipaddr;        ipaddr = (IPADDR *)addr_list->next(ipaddr)) {      for (next = (IPADDR *)addr_list->next(ipaddr); next;           next = (IPADDR *)addr_list->next(next)) {         if (ipaddr->get_sockaddr_len() == next->get_sockaddr_len() &&             memcmp(ipaddr->get_sockaddr(), next->get_sockaddr(),                    ipaddr->get_sockaddr_len()) == 0) {            addr_list->remove(next);         }      }   }   Dmsg1(100, "Addresses %s/n", build_addresses_str(addr_list, allbuf, sizeof(allbuf)));#ifdef HAVE_POLL   nfds = 0;#endif   foreach_dlist(ipaddr, addr_list) {      /*       * Allocate on stack from -- no need to free       */      fd_ptr = (s_sockfd *)alloca(sizeof(s_sockfd));      fd_ptr->port = ipaddr->get_port_net_order();      /*       * Open a TCP socket       */      for (tlog= 60; (fd_ptr->fd=socket(ipaddr->get_family(), SOCK_STREAM, 0)) < 0; tlog -= 10) {         if (tlog <= 0) {            berrno be;            char curbuf[256];            Emsg3(M_ABORT, 0, _("Cannot open stream socket. ERR=%s. Current %s All %s/n"),                       be.bstrerror(),                       ipaddr->build_address_str(curbuf, sizeof(curbuf)),                       build_addresses_str(addr_list, allbuf, sizeof(allbuf)));         }         bmicrosleep(10, 0);      }      /*       * Reuse old sockets       */      if (setsockopt(fd_ptr->fd, SOL_SOCKET, SO_REUSEADDR, (sockopt_val_t)&turnon,           sizeof(turnon)) < 0) {         berrno be;         Emsg1(M_WARNING, 0, _("Cannot set SO_REUSEADDR on socket: %s/n"),               be.bstrerror());      }      tmax = 30 * (60 / 5);        /* wait 30 minutes max */      for (tlog = 0; bind(fd_ptr->fd, ipaddr->get_sockaddr(), ipaddr->get_sockaddr_len()) < 0; tlog -= 5) {         berrno be;         if (tlog <= 0) {            tlog = 2 * 60;         /* Complain every 2 minutes */            Emsg2(M_WARNING, 0, _("Cannot bind port %d: ERR=%s: Retrying .../n"),                  ntohs(fd_ptr->port), be.bstrerror());         }         bmicrosleep(5, 0);         if (--tmax <= 0) {            Emsg2(M_ABORT, 0, _("Cannot bind port %d: ERR=%s./n"), ntohs(fd_ptr->port),                  be.bstrerror());         }      }      listen(fd_ptr->fd, 50);      /* tell system we are ready */      sockfds->append(fd_ptr);//.........这里部分代码省略.........
开发者ID:eneuhauss,项目名称:bareos,代码行数:101,


示例21: two_way_authenticate

//.........这里部分代码省略.........         tls_local_need = BNET_TLS_REQUIRED;      }      if (director->tls_verify_peer) {         verify_list = director->tls_allowed_cns;      }   }   /*    * Timeout Hello after 10 min    */   tid = start_bsock_timer(bs, AUTH_TIMEOUT);   /*    * Sanity check.    */   ASSERT(director->password.encoding == p_encoding_md5);   /*    * Challenge the director    */   auth_success = cram_md5_challenge(bs, director->password.value, tls_local_need, compatible);   if (job_canceled(jcr)) {      auth_success = false;      goto auth_fatal;                   /* quick exit */   }   if (auth_success) {      auth_success = cram_md5_respond(bs, director->password.value, &tls_remote_need, &compatible);      if (!auth_success) {          char addr[64];          char *who = bnet_get_peer(bs, addr, sizeof(addr)) ? bs->who() : addr;          Dmsg1(dbglvl, "cram_get_auth failed for %s/n", who);      }   } else {       char addr[64];       char *who = bnet_get_peer(bs, addr, sizeof(addr)) ? bs->who() : addr;       Dmsg1(dbglvl, "cram_auth failed for %s/n", who);   }   if (!auth_success) {       Emsg1(M_FATAL, 0, _("Incorrect password given by Director at %s./n"),             bs->who());       goto auth_fatal;   }   /*    * Verify that the remote host is willing to meet our TLS requirements    */   if (tls_remote_need < tls_local_need && tls_local_need != BNET_TLS_OK && tls_remote_need != BNET_TLS_OK) {      Jmsg0(jcr, M_FATAL, 0, _("Authorization problem: Remote server did not"           " advertize required TLS support./n"));      Dmsg2(dbglvl, "remote_need=%d local_need=%d/n", tls_remote_need, tls_local_need);      auth_success = false;      goto auth_fatal;   }   /*    * Verify that we are willing to meet the remote host's requirements    */   if (tls_remote_need > tls_local_need && tls_local_need != BNET_TLS_OK && tls_remote_need != BNET_TLS_OK) {      Jmsg0(jcr, M_FATAL, 0, _("Authorization problem: Remote server requires TLS./n"));      Dmsg2(dbglvl, "remote_need=%d local_need=%d/n", tls_remote_need, tls_local_need);      auth_success = false;      goto auth_fatal;   }   if (tls_local_need >= BNET_TLS_OK && tls_remote_need >= BNET_TLS_OK) {      /*       * Engage TLS! Full Speed Ahead!       */      if (!bnet_tls_server(director->tls_ctx, bs, verify_list)) {         Jmsg0(jcr, M_FATAL, 0, _("TLS negotiation failed./n"));         auth_success = false;         goto auth_fatal;      }      if (director->tls_authenticate) {         /* authentication only? */         bs->free_tls();                        /* shutodown tls */      }   }auth_fatal:   if (tid) {      stop_bsock_timer(tid);      tid = NULL;   }   free_pool_memory(dirname);   jcr->director = director;   /*    * Single thread all failures to avoid DOS    */   if (!auth_success) {      P(mutex);      bmicrosleep(6, 0);      V(mutex);   }   return auth_success;}
开发者ID:karcaw,项目名称:bareos,代码行数:101,


示例22: main

int main (int argc, char *argv[]){   int ch;   bool no_signals = false;   bool test_config = false;   pthread_t thid;   char *uid = NULL;   char *gid = NULL;   start_heap = sbrk(0);   setlocale(LC_ALL, "");   bindtextdomain("bareos", LOCALEDIR);   textdomain("bareos");   init_stack_dump();   my_name_is(argc, argv, "bareos-sd");   init_msg(NULL, NULL);   daemon_start_time = time(NULL);   /* Sanity checks */   if (TAPE_BSIZE % B_DEV_BSIZE != 0 || TAPE_BSIZE / B_DEV_BSIZE == 0) {      Emsg2(M_ABORT, 0, _("Tape block size (%d) not multiple of system size (%d)/n"),         TAPE_BSIZE, B_DEV_BSIZE);   }   if (TAPE_BSIZE != (1 << (ffs(TAPE_BSIZE)-1))) {      Emsg1(M_ABORT, 0, _("Tape block size (%d) is not a power of 2/n"), TAPE_BSIZE);   }   while ((ch = getopt(argc, argv, "c:d:fg:mpstu:v?")) != -1) {      switch (ch) {      case 'c':                    /* configuration file */         if (configfile != NULL) {            free(configfile);         }         configfile = bstrdup(optarg);         break;      case 'd':                    /* debug level */         if (*optarg == 't') {            dbg_timestamp = true;         } else {            debug_level = atoi(optarg);            if (debug_level <= 0) {               debug_level = 1;            }         }         break;      case 'f':                    /* run in foreground */         foreground = true;         break;      case 'g':                    /* set group id */         gid = optarg;         break;      case 'm':                    /* print kaboom output */         prt_kaboom = true;         break;      case 'p':                    /* proceed in spite of I/O errors */         forge_on = true;         break;      case 's':                    /* no signals */         no_signals = true;         break;      case 't':         test_config = true;         break;      case 'u':                    /* set uid */         uid = optarg;         break;      case 'v':                    /* verbose */         verbose++;         break;      case '?':      default:         usage();         break;      }   }   argc -= optind;   argv += optind;   if (argc) {      if (configfile != NULL) {         free(configfile);      }      configfile = bstrdup(*argv);      argc--;      argv++;   }   if (argc)      usage();//.........这里部分代码省略.........
开发者ID:AlD,项目名称:bareos,代码行数:101,


示例23: save_resource

/* * Save the new resource by chaining it into the head list for * the resource. If this is pass 2, we update any resource * pointers (currently only in the Job resource). */void save_resource(int type, RES_ITEM *items, int pass){   URES *res;   int rindex = type - r_first;   int i, size = 0;   int error = 0;   /*    * Ensure that all required items are present    */   for (i=0; items[i].name; i++) {      if (items[i].flags & ITEM_REQUIRED) {            if (!bit_is_set(i, res_all.dir_res.hdr.item_present)) {               Emsg2(M_ABORT, 0, _("%s item is required in %s resource, but not found./n"),                 items[i].name, resources[rindex]);             }      }   }   /*    * During pass 2, we looked up pointers to all the resources    * referrenced in the current resource, , now we    * must copy their address from the static record to the allocated    * record.    */   if (pass == 2) {      switch (type) {      /*       * Resources not containing a resource       */      case R_DIRECTOR:         break;      case R_CONSOLE:      case R_CONSOLE_FONT:         break;      default:         Emsg1(M_ERROR, 0, _("Unknown resource type %d/n"), type);         error = 1;         break;      }      /*       * Note, the resoure name was already saved during pass 1,       * so here, we can just release it.       */      if (res_all.dir_res.hdr.name) {         free(res_all.dir_res.hdr.name);         res_all.dir_res.hdr.name = NULL;      }      if (res_all.dir_res.hdr.desc) {         free(res_all.dir_res.hdr.desc);         res_all.dir_res.hdr.desc = NULL;      }      return;   }   /*    * The following code is only executed during pass 1    */   switch (type) {   case R_DIRECTOR:      size = sizeof(DIRRES);      break;   case R_CONSOLE_FONT:      size = sizeof(CONFONTRES);      break;   case R_CONSOLE:      size = sizeof(CONRES);      break;   default:      printf(_("Unknown resource type %d/n"), type);      error = 1;      break;   }   /*    * Common    */   if (!error) {      res = (URES *)malloc(size);      memcpy(res, &res_all, size);      if (!res_head[rindex]) {         res_head[rindex] = (RES *)res; /* store first entry */      } else {         RES *next, *last;         /*          * Add new res to end of chain          */         for (last=next=res_head[rindex]; next; next=next->next) {            last = next;            if (strcmp(next->name, res->dir_res.hdr.name) == 0) {               Emsg2(M_ERROR_TERM, 0,                  _("Attempt to define second %s resource named /"%s/" is not permitted./n"),                  resources[rindex].name, res->dir_res.hdr.name);            }//.........这里部分代码省略.........
开发者ID:eneuhauss,项目名称:bareos,代码行数:101,


示例24: main

//.........这里部分代码省略.........      case 'v':         verbose++;         break;      case 'V':                    /* Volume name */         VolumeName = optarg;         break;      case '?':      default:         usage();      } /* end switch */   } /* end while */   argc -= optind;   argv += optind;   if (!argc) {      Pmsg0(0, _("No archive name specified/n"));      usage();   }   if (configfile == NULL) {      configfile = bstrdup(CONFIG_FILE);   }   my_config = new_config_parser();   parse_sd_config(my_config, configfile, M_ERROR_TERM);   LockRes();   me = (STORES *)GetNextRes(R_STORAGE, NULL);   if (!me) {      UnlockRes();      Emsg1(M_ERROR_TERM, 0, _("No Storage resource defined in %s. Cannot continue./n"),            configfile);   }   UnlockRes();  if (DirectorName) {      foreach_res(director, R_DIRECTOR) {         if (bstrcmp(director->hdr.name, DirectorName)) {            break;         }      }      if (!director) {         Emsg2(M_ERROR_TERM, 0, _("No Director resource named %s defined in %s. Cannot continue./n"),               DirectorName, configfile);      }   }   load_sd_plugins(me->plugin_directory, me->plugin_names);   read_crypto_cache(me->working_directory, "bareos-sd",                     get_first_port_host_order(me->SDaddrs));   if (ff->included_files_list == NULL) {      add_fname_to_include_list(ff, 0, "/");   }   for (i=0; i < argc; i++) {      if (bsrName) {         bsr = parse_bsr(NULL, bsrName);      }      jcr = setup_jcr("bls", argv[i], bsr, director, VolumeName, 1); /* acquire for read */      if (!jcr) {         exit(1);
开发者ID:AlD,项目名称:bareos,代码行数:67,


示例25: save_resource

/* * Save the new resource by chaining it into the head list for * the resource. If this is pass 2, we update any resource * pointers because they may not have been defined until * later in pass 1. */void save_resource(int type, RES_ITEM *items, int pass){   URES *res;   int rindex = type - R_FIRST;   int i;   int error = 0;   /*    * Ensure that all required items are present    */   for (i = 0; items[i].name; i++) {      if (items[i].flags & CFG_ITEM_REQUIRED) {         if (!bit_is_set(i, res_all.res_monitor.hdr.item_present)) {               Emsg2(M_ERROR_TERM, 0, _("%s item is required in %s resource, but not found./n"),                  items[i].name, resources[rindex]);         }      }      /* If this triggers, take a look at lib/parse_conf.h */      if (i >= MAX_RES_ITEMS) {         Emsg1(M_ERROR_TERM, 0, _("Too many items in %s resource/n"), resources[rindex]);      }   }   /*    * During pass 2 in each "store" routine, we looked up pointers    * to all the resources referrenced in the current resource, now we    * must copy their addresses from the static record to the allocated    * record.    */   if (pass == 2) {      switch (type) {      /*       * Resources not containing a resource       */      case R_MONITOR:      case R_CLIENT:      case R_STORAGE:      case R_DIRECTOR:      case R_CONSOLE_FONT:         break;      default:         Emsg1(M_ERROR, 0, _("Unknown resource type %d in save_resource./n"), type);         error = 1;         break;      }      /*       * Note, the resource name was already saved during pass 1,       * so here, we can just release it.       */      if (res_all.res_monitor.hdr.name) {         free(res_all.res_monitor.hdr.name);         res_all.res_monitor.hdr.name = NULL;      }      if (res_all.res_monitor.hdr.desc) {         free(res_all.res_monitor.hdr.desc);         res_all.res_monitor.hdr.desc = NULL;      }      return;   }   /*    * Common    */   if (!error) {      res = (URES *)malloc(resources[rindex].size);      memcpy(res, &res_all, resources[rindex].size);      if (!res_head[rindex]) {        res_head[rindex] = (RES *)res; /* store first entry */         Dmsg3(900, "Inserting first %s res: %s index=%d/n", res_to_str(type),         res->res_monitor.hdr.name, rindex);      } else {         RES *next, *last;         /*          * Add new res to end of chain          */         for (last = next = res_head[rindex]; next; next=next->next) {            last = next;            if (strcmp(next->name, res->res_monitor.hdr.name) == 0) {               Emsg2(M_ERROR_TERM, 0,                     _("Attempt to define second %s resource named /"%s/" is not permitted./n"),               resources[rindex].name, res->res_monitor.hdr.name);            }         }         last->next = (RES *)res;         Dmsg4(900, "Inserting %s res: %s index=%d pass=%d/n", res_to_str(type),         res->res_monitor.hdr.name, rindex, pass);      }   }}
开发者ID:AlD,项目名称:bareos,代码行数:95,


示例26: write_record_to_block

//.........这里部分代码省略.........             * the header did not fit into the block, so flush the current             * block and come back to st_header and try again on the next block.             */            goto bail_out;         }         if (block_write_navail(block) == 0) {            /*             * The header fit, but no bytes of data will fit,             * so flush this block and start the next block with a             * continuation header.             */            rec->state = st_header_cont;            goto bail_out;         }         /*          * The header fit, and at least one byte of data will fit,          * so move to the st_data state and start filling the block          * with data bytes          */         rec->state = st_data;         continue;      case st_header_cont:         /*          * Write continuation header          */         n = write_header_to_block(block, rec, -rec->Stream);         if (n < 0) {            /*             * The continuation header wouldn't fit, which is impossible             * unless something is broken             */            Emsg0(M_ABORT, 0, _("couldn't write continuation header/n"));         }         /*          * After successfully writing a continuation header, we always start writing          * data, even if none will fit into this block.          */         rec->state = st_data;         if (block_write_navail(block) == 0) {            /*             * The header fit, but no bytes of data will fit,             * so flush the block and start the next block with             * data bytes             */            goto bail_out;       /* Partial transfer */         }         continue;      case st_data:         /*          * Write normal data          *          * Part of it may have already been transferred, and we          * may not have enough room to transfer the whole this time.          */         if (rec->remainder > 0) {            n = write_data_to_block(block, rec);            if (n < 0) {               /*                * error appending data to block should be impossible                * unless something is broken                */               Emsg0(M_ABORT, 0, _("data write error/n"));            }            rec->remainder -= n;            if (rec->remainder > 0) {               /*                * Could not fit all of the data bytes into this block, so                * flush the current block, and start the next block with a                * continuation header                */               rec->state = st_header_cont;               goto bail_out;            }         }         rec->remainder = 0;               /* did whole transfer */         rec->state = st_none;         retval = true;         goto bail_out;      default:         Emsg1(M_ABORT, 0, _("Something went wrong. Unknown state %d./n"), rec->state);         rec->state = st_none;         retval = true;         goto bail_out;      }   }bail_out:   return retval;}
开发者ID:wisre,项目名称:bareos,代码行数:101,


示例27: record_cb

//.........这里部分代码省略.........         int status = Z_BUF_ERROR;         if (rec->maskedStream == STREAM_SPARSE_GZIP_DATA) {            ser_declare;            uint64_t faddr;            char ec1[50];            wbuf = rec->data + OFFSET_FADDR_SIZE;            wsize = rec->data_len - OFFSET_FADDR_SIZE;            ser_begin(rec->data, OFFSET_FADDR_SIZE);            unser_uint64(faddr);            if (fileAddr != faddr) {               fileAddr = faddr;               if (blseek(&bfd, (boffset_t)fileAddr, SEEK_SET) < 0) {                  berrno be;                  Emsg3(M_ERROR, 0, _("Seek to %s error on %s: ERR=%s/n"),                     edit_uint64(fileAddr, ec1), attr->ofname, be.bstrerror());                  extract = false;                  return true;               }            }         } else {            wbuf = rec->data;            wsize = rec->data_len;         }         while (compress_len < 10000000 && (status = uncompress((Byte *)compress_buf, &compress_len,                                 (const Byte *)wbuf, (uLong)wsize)) == Z_BUF_ERROR) {            /* The buffer size is too small, try with a bigger one */            compress_len = 2 * compress_len;            compress_buf = check_pool_memory_size(compress_buf,                                                  compress_len);         }         if (status != Z_OK) {            Emsg1(M_ERROR, 0, _("Uncompression error. ERR=%d/n"), status);            extract = false;            return true;         }         Dmsg2(100, "Write uncompressed %d bytes, total before write=%d/n", compress_len, total);         store_data(&bfd, compress_buf, compress_len);         total += compress_len;         fileAddr += compress_len;         Dmsg2(100, "Compress len=%d uncompressed=%d/n", rec->data_len,            compress_len);      }#else      if (extract) {         Emsg0(M_ERROR, 0, _("GZIP data stream found, but GZIP not configured!/n"));         extract = false;         return true;      }#endif      break;   /* Compressed data stream */   case STREAM_COMPRESSED_DATA:   case STREAM_SPARSE_COMPRESSED_DATA:   case STREAM_WIN32_COMPRESSED_DATA:      if (extract) {         uint32_t comp_magic, comp_len;         uint16_t comp_level, comp_version;#ifdef HAVE_LZO         lzo_uint compress_len;         const unsigned char *cbuf;         int r, real_compress_len;#endif
开发者ID:eneuhauss,项目名称:bareos,代码行数:67,



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


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