示例#1
0
	void symboltable::print(std::ostream& s) const
	{
		for(sid i = 0; i < index.size(); i++)
		{
			print_name(i, s << i << ": ");
			s << std::endl;
		}
	}
示例#2
0
int main(int argc, char *argv[]) 
{
	printf("Hello, World!\n");
	printf("Git is fun!\n");

	print_name("edwin");
	return 0;
}
示例#3
0
文件: print.c 项目: chenggongtc/myls
void
print_long(OBJ *obj)
{
	struct stat *st;
	FTSENT      *p;
	char        mode[MODE_BUFF_SIZE];

	p = obj->obj_list;

	if(!obj->obj_isroot)
		print_total(obj->obj_size_total);

	while (p != NULL) {
		if (p->fts_number == FTS_NO_PRINT) {
			p = p->fts_link;
			continue;
		}

		st = p->fts_statp;

		/* print inode */
		if (f_ino)
			printf("%*"PRIuMAX" ", obj->obj_ino_max,
				(uintmax_t)st->st_ino);

		/* print number of blocks */
		if (f_block) {	
			print_block((int64_t)st->st_blocks * DEFAULT_BSIZE, 
				    obj->obj_block_max);
		}
		
		/* print mode */
		strmode(st->st_mode, mode);
		printf("%11s ", mode);

		/* print number of links */
		printf("%*"PRIuMAX" ", obj->obj_link_max, 
			(uintmax_t)st->st_nlink);

		/* print owner and group */
		print_user_and_group(st->st_uid, st->st_gid, 
				      obj->obj_user_max, obj->obj_group_max);

		/* print size */
		if (S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode))
			print_device(st->st_rdev, obj->obj_major_max,
					obj->obj_minor_max);
		else
			print_size(st->st_size, obj->obj_size_max);

		print_date(st);
		print_name(p, WITH_LINK);

		putchar('\n');

		p = p->fts_link;
	}
}
示例#4
0
void traite_ligne(char *ch, int if_cntx)
{
static char *lvide="  ";
char *word,*tagg;
int nb,i,j;

if (ch)
 {
 word=strtok(ch," \t\n");
 if (word) tagg=strtok(NULL," \t\n"); else tagg=NULL;
 if ((!word)||(!tagg)) { fprintf(stderr,"ERROR: bad format in input file line %d\n",nb+1); exit(0); }
 if (strlen(word)>=TailleMot) word[TailleMot-2]='\0';
 if (strlen(tagg)>=TailleMot) tagg[TailleMot-2]='\0';
 }
else tagg=word=lvide;

for(i=1;i<WindowSize;i++)
 {
 strcpy(T_word[i-1],T_word[i]);
 strcpy(T_tagg[i-1],T_tagg[i]);
 T_flag[i-1]=T_flag[i];
 }
strcpy(T_word[WindowSize-1],word);
strcpy(T_tagg[WindowSize-1],tagg);
T_flag[WindowSize-1]=0;

if (T_flag[ContextSize]==0)
 {
 if ((find_name(&j))&&((j>ContextSize+1)||(strlen(T_word[ContextSize])>1)))
  {
  if (if_cntx)
   {
   for (i=0;i<ContextSize;i++) { if (i>0) printf(" "); printf("%s",T_word[i]); }
   printf(" # "); print_name(j);
   for (i=1;i<ContextSize;i++) { if (i>1) printf(" "); printf("%s",T_word[i]); }
   printf(" # "); print_name(j);
   for (i=2;i<ContextSize;i++) { if (i>2) printf(" "); printf("%s",T_word[i]); }
   printf(" # "); print_name(j);
   for (i=3;i<ContextSize;i++) { if (i>3) printf(" "); printf("%s",T_word[i]); }
   printf(" # "); print_name(j);
   }
  else print_name(j);
  }
 }
}
示例#5
0
static void print_string_and_value(char *name,const char *str,
				   unsigned char value)
    {
    print_name(name);

    printf("%s", str);
    printf(" (0x%x)", value);
    printf("\n");
    }
示例#6
0
static void tail_object_deleted(confdb_handle_t handle,
	hdb_handle_t parent_object_handle,
	const void *name_pt,
	size_t name_len)
{
	fputs("object_deleted>", stdout);
	print_name(stdout, name_pt, name_len);
	fputs("\n", stdout);
}
  // for LIR
  virtual void visit(LIR_OpVisitState* visit) {
#ifndef PRODUCT
    if (LIRTracePeephole && Verbose) {
      tty->print("no visitor for ");
      print_name(tty);
      tty->cr();
    }
#endif
  }
示例#8
0
文件: dev.c 项目: dl5rcw/bareos
/*
 * Open a device.
 */
void DEVICE::open_device(DCR *dcr, int omode)
{
   POOL_MEM archive_name(PM_FNAME);

   get_autochanger_loaded_slot(dcr);

   /*
    * Handle opening of File Archive (not a tape)
    */
   pm_strcpy(archive_name, dev_name);

   /*
    * If this is a virtual autochanger (i.e. changer_res != NULL) we simply use
    * the device name, assuming it has been appropriately setup by the "autochanger".
    */
   if (!device->changer_res || device->changer_command[0] == 0) {
      if (VolCatInfo.VolCatName[0] == 0) {
         Mmsg(errmsg, _("Could not open file device %s. No Volume name given.\n"),
            print_name());
         clear_opened();
         return;
      }

      if (!IsPathSeparator(archive_name.c_str()[strlen(archive_name.c_str())-1])) {
         pm_strcat(archive_name, "/");
      }
      pm_strcat(archive_name, getVolCatName());
   }

   mount(dcr, 1);                     /* do mount if required */

   open_mode = omode;
   set_mode(omode);

   /*
    * If creating file, give 0640 permissions
    */
   Dmsg3(100, "open disk: mode=%s open(%s, 0x%x, 0640)\n", mode_to_str(omode),
         archive_name.c_str(), oflags);

   if ((m_fd = d_open(archive_name.c_str(), oflags, 0640)) < 0) {
      berrno be;
      dev_errno = errno;
      Mmsg2(errmsg, _("Could not open: %s, ERR=%s\n"), archive_name.c_str(),
            be.bstrerror());
      Dmsg1(100, "open failed: %s", errmsg);
   }

   if (m_fd >= 0) {
      dev_errno = 0;
      file = 0;
      file_addr = 0;
   }

   Dmsg1(100, "open dev: disk fd=%d opened\n", m_fd);
}
示例#9
0
static void
do_find(isc_boolean_t want_event) {
	isc_result_t result;
	isc_boolean_t done = ISC_FALSE;
	unsigned int options;

	options = DNS_ADBFIND_INET | DNS_ADBFIND_INET6;
	if (want_event)
		options |= DNS_ADBFIND_WANTEVENT | DNS_ADBFIND_EMPTYEVENT;
	dns_fixedname_init(&target);
	result = dns_adb_createfind(view->adb, task, adb_callback, NULL,
				    dns_fixedname_name(&fixed),
				    dns_rootname, 0, options, 0,
				    dns_fixedname_name(&target), 0,
				    &find);
	if (result == ISC_R_SUCCESS) {
		if (!ISC_LIST_EMPTY(find->list)) {
			/*
			 * We have at least some of the addresses for the
			 * name.
			 */
			INSIST((find->options & DNS_ADBFIND_WANTEVENT) == 0);
			print_addresses(find);
			done = ISC_TRUE;
		} else {
			/*
			 * We don't know any of the addresses for this
			 * name.
			 */
			if ((find->options & DNS_ADBFIND_WANTEVENT) == 0) {
				/*
				 * And ADB isn't going to send us any events
				 * either.  This query loses.
				 */
				done = ISC_TRUE;
			}
			/*
			 * If the DNS_ADBFIND_WANTEVENT flag was set, we'll
			 * get an event when something happens.
			 */
		}
	} else if (result == DNS_R_ALIAS) {
		print_name(dns_fixedname_name(&target));
		done = ISC_TRUE;
	} else {
		printf("dns_adb_createfind() returned %s\n",
		       isc_result_totext(result));
		done = ISC_TRUE;
	}

	if (done) {
		if (find != NULL)
			dns_adb_destroyfind(&find);
		isc_app_shutdown();
	}
}
示例#10
0
static void print_hexdump(const char *name,
			  const unsigned char *data,
			  unsigned int len)
    {
    print_name(name);

    printf("len=%d, data=0x", len);
    print_hex(data,len);
    printf("\n");
    }
示例#11
0
static void print_hexdump_data(const char *name,
			       const unsigned char *data,
			       unsigned int len)
    {
    print_name(name);

    printf("0x");
    print_hex(data,len);
    printf("\n");
    }
示例#12
0
static void tail_key_changed(confdb_handle_t handle,
	confdb_change_type_t change_type,
	hdb_handle_t parent_object_handle,
	hdb_handle_t object_handle,
	const void *object_name_pt,
	size_t  object_name_len,
	const void *key_name_pt,
	size_t key_name_len,
	const void *key_value_pt,
	size_t key_value_len)
{
	/* printf("key_changed> %.*s.%.*s=%.*s\n", */
	fputs("key_changed> ", stdout);
	print_name (stdout, object_name_pt, object_name_len);
	fputs(".", stdout);
	print_name (stdout, key_name_pt, key_name_len);
	fputs("=", stdout);
	print_name (stdout, key_value_pt, key_value_len);
	fputs("\n", stdout);
}
示例#13
0
文件: dev.c 项目: dl5rcw/bareos
/*
 * Position device to end of medium (end of data)
 *
 * Returns: true  on succes
 *          false on error
 */
bool DEVICE::eod(DCR *dcr)
{
   boffset_t pos;

   if (m_fd < 0) {
      dev_errno = EBADF;
      Mmsg1(errmsg, _("Bad call to eod. Device %s not open\n"), print_name());
      return false;
   }

   if (is_vtl()) {
      return true;
   }

   Dmsg0(100, "Enter eod\n");
   if (at_eot()) {
      return true;
   }

   clear_eof();         /* remove EOF flag */

   block_num = file = 0;
   file_size = 0;
   file_addr = 0;

   pos = lseek(dcr, (boffset_t)0, SEEK_END);
   Dmsg1(200, "====== Seek to %lld\n", pos);

   if (pos >= 0) {
      update_pos(dcr);
      set_eot();
      return true;
   }

   dev_errno = errno;
   berrno be;
   Mmsg2(errmsg, _("lseek error on %s. ERR=%s.\n"), print_name(), be.bstrerror());
   Dmsg0(100, errmsg);

   return false;
}
示例#14
0
/* Rewind file device */
bool DEVICE::rewind(DCR *dcr)
{
   Dmsg3(400, "rewind res=%d fd=%d %s\n", num_reserved(), m_fd, print_name());
   state &= ~(ST_EOT|ST_EOF|ST_WEOT);  /* remove EOF/EOT flags */
   block_num = file = 0;
   file_size = 0;
   file_addr = 0;
   if (m_fd < 0) {
      return false;
   }
   if (is_file()) {
      if (lseek(dcr, (boffset_t)0, SEEK_SET) < 0) {
         berrno be;
         dev_errno = errno;
         Mmsg2(errmsg, _("lseek error on %s. ERR=%s.\n"),
            print_name(), be.bstrerror());
         return false;
      }
   }
   return true;
}
示例#15
0
文件: kernel.c 项目: Peekmo/nasm
int main()
{
    clear_screen();
    print_name();

    // Loading Kernel OK
    printloc("Loading kernel...", 8, 2, RED);
    printloc("[OK]", 8, 30, GREEN);
    printloc("Building the world...", 9, 2, RED);
    printloc("[OK]", 9, 30, GREEN);

    printloc("You can now doing nothing :)", 11, 2, CYAN);
}
示例#16
0
文件: ls.c 项目: akat1/impala
void
long_entry(const char *file, const struct stat *st)
{
    printf("%s%s %2u %7s %7s %10u %s\n",
        print_serial(st),
        mode2str(st->st_mode),
        st->st_nlink,
        print_uid(st),
        print_gid(st),
        st->st_size,
        print_name(file, st)
     );
}
示例#17
0
文件: dev.c 项目: aussendorf/bareos
/*
 * Open the device with the operating system and
 * initialize buffer pointers.
 *
 * Returns: true on success
 *          false on error
 *
 * Note, for a tape, the VolName is the name we give to the
 * volume (not really used here), but for a file, the
 * VolName represents the name of the file to be created/opened.
 * In the case of a file, the full name is the device name
 * (archive_name) with the VolName concatenated.
 */
bool DEVICE::open(DCR *dcr, int omode)
{
   char preserve[ST_BYTES];

   clear_all_bits(ST_MAX, preserve);
   if (is_open()) {
      if (open_mode == omode) {
         return true;
      } else {
         d_close(m_fd);
         clear_opened();
         Dmsg0(100, "Close fd for mode change.\n");

         if (bit_is_set(ST_LABEL, state))
            set_bit(ST_LABEL, preserve);
         if (bit_is_set(ST_APPENDREADY, state))
            set_bit(ST_APPENDREADY, preserve);
         if (bit_is_set(ST_READREADY, state))
            set_bit(ST_READREADY, preserve);
      }
   }

   if (dcr) {
      dcr->setVolCatName(dcr->VolumeName);
      VolCatInfo = dcr->VolCatInfo;    /* structure assign */
   }

   Dmsg4(100, "open dev: type=%d dev_name=%s vol=%s mode=%s\n", dev_type,
         print_name(), getVolCatName(), mode_to_str(omode));

   clear_bit(ST_LABEL, state);
   clear_bit(ST_APPENDREADY, state);
   clear_bit(ST_READREADY, state);
   clear_bit(ST_EOT, state);
   clear_bit(ST_WEOT, state);
   clear_bit(ST_EOF, state);

   label_type = B_BAREOS_LABEL;

   Dmsg1(100, "call open_device mode=%s\n", mode_to_str(omode));
   open_device(dcr, omode);

   /*
    * Reset any important state info
    */
   clone_bits(ST_MAX, preserve, state);

   Dmsg2(100, "preserve=0x%x fd=%d\n", preserve, m_fd);

   return m_fd >= 0;
}
示例#18
0
bool Clocks::print_c( std::ostream& o, unsigned int i ) const {
    ASSERT( i > 0 );
    raw_t upper = data[ i * dim + 0 ];
    raw_t lower = data[ 0 * dim + i ];
    if ( lower != dbm_LE_ZERO )
        o << ( -dbm_raw2bound( lower ) ) << boundEq( lower );
    if ( lower != dbm_LE_ZERO || upper != dbm_LS_INFINITY )
        print_name( o, i );
    else
        return false;
    if ( upper != dbm_LS_INFINITY )
        o << boundEq( upper ) << dbm_raw2bound( upper );
    return true;
}
示例#19
0
void frame::print() const {
  std->print("[%s frame: fp = %#lx, sp = %#lx, pc = %#lx", print_name(), fp(), sp(), pc());
  if (is_compiled_frame()) {
    std->print(", nm = %#x", findNMethod(pc()));
  } else if (is_interpreted_frame()) {
    std->print(", hp = %#x, method = %#x", hp(), method());
  }
  std->print_cr("]");

  if (PrintLongFrames) {
    for (oop* p = sp(); p < (oop*)fp(); p++)
      std->print_cr("  - 0x%lx: 0x%lx", p, *p);
  }
}
示例#20
0
static void
search_mktidn(mddl_clo_t clo, mddl_marketIdentifier_t mi, bool match)
{
	const char *code = clo->name->code;
	const char *scheme = clo->name->scheme;

	if (match ||
	    (match = code_match_p(mi->code, mi->ncode, scheme, code))) {
		/* mi contains code, brilliant, just print it all */
		for (size_t i = 0; i < mi->nname; i++) {
			print_name(clo, mi->name + i, "mi");
		}
	}
	return;
}
示例#21
0
static void
search_issref(mddl_clo_t clo, mddl_issuerRef_t ir, bool match)
{
	const char *code = clo->name->code;
	const char *scheme = clo->name->scheme;

	if (match ||
	    (match = code_match_p(ir->code, ir->ncode, scheme, code))) {
		/* ah, ir matches, good, just print all them names */
		for (size_t i = 0; i < ir->nname; i++) {
			print_name(clo, ir->name + i, "ir");
		}
	}
	return;
}
示例#22
0
void DEVICE::attach_dcr_to_dev(DCR *dcr)
{
   JCR *jcr = dcr->jcr;

   Lock_dcrs();
   jcr = dcr->jcr;
   if (jcr) Dmsg1(500, "JobId=%u enter attach_dcr_to_dev\n", (uint32_t)jcr->JobId);
   /* ***FIXME*** return error if dev not initiated */
   if (!dcr->attached_to_dev && initiated && jcr && jcr->getJobType() != JT_SYSTEM) {
      Dmsg4(200, "Attach Jid=%d dcr=%p size=%d dev=%s\n", (uint32_t)jcr->JobId,
         dcr, attached_dcrs->size(), print_name());
      attached_dcrs->append(dcr);  /* attach dcr to device */
      dcr->attached_to_dev = true;
   }
   Unlock_dcrs();
}
示例#23
0
	void symboltable::print(const typecontext& c, std::ostream& s) const
	{
		for(sid i = 0; i < index.size(); i++)
		{
			print_name(i, s << i << ": ");
			
			s << " = ";
			
			if(c.is_registered(i))
				c[i]->print(s);
			else
				s << "undef";
				
			s << std::endl;
		}
	}
示例#24
0
static void
search_insidn(mddl_clo_t clo, mddl_instrumentIdentifier_t ii, bool match)
{
	const char *code = clo->name->code;
	const char *scheme = clo->name->scheme;

	if (match ||
	    (match = code_match_p(ii->code, ii->ncode, scheme, code))) {
		/* ah, ii matches, good, just print all them names */
		for (size_t i = 0; i < ii->nname; i++) {
			print_name(clo, ii->name + i, "ii");
		}
	}
	for (size_t i = 0; i < ii->nmarketIdentifier; i++) {
		search_mktidn(clo, ii->marketIdentifier + i, match);
	}
	return;
}
示例#25
0
文件: dev.c 项目: dl5rcw/bareos
/*
 * Free memory allocated for the device
 */
void DEVICE::term()
{
   Dmsg1(900, "term dev: %s\n", print_name());

   /*
    * On termination we don't have any DCRs left
    * so we call close with a NULL argument as
    * the dcr argument is only used in the unmount
    * method to generate a plugin_event we just check
    * there if the dcr is not NULL and otherwise skip
    * the plugin event generation.
    */
   close(NULL);

   if (dev_name) {
      free_memory(dev_name);
      dev_name = NULL;
   }
   if (dev_options) {
      free_memory(dev_options);
      dev_options = NULL;
   }
   if (prt_name) {
      free_memory(prt_name);
      prt_name = NULL;
   }
   if (errmsg) {
      free_pool_memory(errmsg);
      errmsg = NULL;
   }
   pthread_mutex_destroy(&m_mutex);
   pthread_cond_destroy(&wait);
   pthread_cond_destroy(&wait_next_vol);
   pthread_mutex_destroy(&spool_mutex);
// rwl_destroy(&lock);
   if (attached_dcrs) {
      delete attached_dcrs;
      attached_dcrs = NULL;
   }
   if (device) {
      device->dev = NULL;
   }
   delete this;
}
示例#26
0
int main(int argc, char *argv[])
{
	if (argc <= 1) {
		usage();
		return 1;
	}

	int fd = open(argv[1], O_RDONLY);

	if (fd == -1) {
		printf("Could not open %s\n", argv[1]);
		return 1;
	}

	print_name(fd);

	close(fd);
	return 0;
}
示例#27
0
void
NetStream::no_tcp_delay(
   )
{
   // DON'T "BLOCK" WHEN USING TCP
   //"on the sender's side, to insure that TCP doesn't send too many small
   //packets, it refuses to send a packet if there is an ack outstanding
   //unless it is has good-sized (i.e., big) packet to send. This feature
   //can be turned off (e.g., X turns it off) by specifying the TCP_NODELAY
   //option to setsockopt -- see the man pages for setsockopt and tcp." -twd
   if (!Config::get_var_bool("DO_TCP_DELAY",false,true)) {
      int on=1;
      if (setsockopt(_fd, IPPROTO_TCP, TCP_NODELAY, (char *)&on, sizeof(on))) {
         cerr << "NetStream::no_tcp_delay-  setsockopt(TCP_NODELAY) on " <<
            print_name() << " (" << _fd<< ")";
         perror("");
      }
   }
}
示例#28
0
文件: print_ls.c 项目: jaybi42/ft_ls
void			print_ls(t_list *list, t_arg *arg_list)
{
	t_maxlen	maxlen;

	ft_bzero(&maxlen, sizeof(t_maxlen));
	get_maxlen(arg_list->arg[10], list, &maxlen);
	if (list != NULL && arg_list->arg[9] == 1 &&
		S_ISDIR(((t_file *)list->content)->mode) == 1)
		print_total(list);
	while (list != NULL)
	{
		if (arg_list->arg[8] == 1)
			print_ino(((t_file *)list->content)->ino, maxlen.ino);
		if (list != NULL && arg_list->arg[9] == 1)
			print_ls_ext((t_file *)list->content, arg_list, &maxlen);
		print_name((t_file *)list->content, arg_list->arg[9]);
		list = list->next;
	}
}
示例#29
0
文件: tag.c 项目: DaneTheory/libgit2
/** Tag listing: Lookup tags based on ref name and dispatch to print */
static int each_tag(const char *name, tag_state *state)
{
	git_repository *repo = state->repo;
	git_object *obj;

	check_lg2(git_revparse_single(&obj, repo, name),
			"Failed to lookup rev", name);

	switch (git_object_type(obj)) {
		case GIT_OBJ_TAG:
			print_tag((git_tag *) obj, state);
			break;
		case GIT_OBJ_COMMIT:
			print_commit((git_commit *) obj, name, state);
			break;
		default:
			print_name(name);
	}

	git_object_free(obj);
	return 0;
}
示例#30
0
/*
 * Prints brief annotation for a row of data values
 */
static void
annotate_brief(
    const ncvar_t *vp,		/* variable */
    const size_t *cor,		/* corner coordinates */
    size_t vdims[]		/* variable dimension sizes */
    )
{
    int vrank = vp->ndims;
    int id;
    printf ("// ");
    print_name(vp->name);
    printf("(");

    switch (formatting_specs.data_lang) {
    case LANG_C:
	/* print brief comment with C variable indices */
	for (id = 0; id < vrank-1; id++)
	    printf("%lu,", (unsigned long)cor[id]);
	if (vdims[vrank-1] == 1)
	    printf("0");
	else
	    printf(" 0-%lu", (unsigned long)vdims[vrank-1]-1);
	break;
    case LANG_F:
	/* print brief comment with Fortran variable indices */
	if (vdims[vrank-1] == 1)
	    printf("1");
	else
	    printf("1-%lu ", (unsigned long)vdims[vrank-1]);
	for (id = vrank-2; id >=0 ; id--) {
	    printf(",%lu", (unsigned long)(1 + cor[id]));
	}
	break;
    }
    printf(")\n");
    indent_out();
    printf("    ");
    set_indent(4 + indent_get());
}