Example #1
0
static void
roster_handler(int x, struct xmpp *xmpp)
{
    struct xml_data *d;
    char *jid, *name, *sub;
    for (d = xml_node_data(xml_node_find(x, "query", &xmpp->xml.mem),
                           &xmpp->xml.mem);
            d;
            d = xml_data_next(d, &xmpp->xml.mem)) {
        if (d->type != XML_NODE)
            continue;
        jid = xml_node_find_attr(d->value, "jid", &xmpp->xml.mem);
        name = xml_node_find_attr(d->value, "name", &xmpp->xml.mem);
        sub = xml_node_find_attr(d->value, "subscription", &xmpp->xml.mem);
        print_msg("* %s - %s - [%s]\n", name ? name : "", jid, sub);
    }
    print_msg("End of roster\n");
    for (d = xml_node_data(xml_node_find(x, "query", &xmpp->xml.mem),
                           &xmpp->xml.mem);
            d;
            d = xml_data_next(d, &xmpp->xml.mem)) {
        if (d->type != XML_NODE)
            continue;
        jid = xml_node_find_attr(d->value, "jid", &xmpp->xml.mem);
        if (jid)
            xmpp_printf(xmpp, "<presence type='probe' to='%s'/>", jid);
    }
}
Example #2
0
File: ji.c Project: placek/ji
static int
roster_hook(int x, struct xmpp *xmpp)
{
  struct xml_data *d;
  char *jid, *name, *sub;

  for (d = xml_node_data(xml_node_find(x, "query", &xmpp->xml.mem),
                         &xmpp->xml.mem);
       d; d = xml_data_next(d, &xmpp->xml.mem)) {
    if (d->type != XML_NODE)
      continue;
    jid = xml_node_find_attr(d->value, "jid", &xmpp->xml.mem);
    name = xml_node_find_attr(d->value, "name", &xmpp->xml.mem);
    sub = xml_node_find_attr(d->value, "subscription", &xmpp->xml.mem);
    print_msg(0, "", "* %s - %s - [%s]\n", name ? name : "", jid, sub);
  }
  print_msg(0, "", "End of /R list.\n");
  for (d = xml_node_data(xml_node_find(x, "query", &xmpp->xml.mem),
                         &xmpp->xml.mem);
       d; d = xml_data_next(d, &xmpp->xml.mem)) {
    if (d->type != XML_NODE)
      continue;
    jid = xml_node_find_attr(d->value, "jid", &xmpp->xml.mem);
    request_presence(xmpp, jid);
  }
  return 0;
}
Example #3
0
int main(void)
{
  void print_msg(char *);

  print_msg("hello");
  print_msg("world\n");
}
Example #4
0
void give_exp(player_info_t * player, const int amount)
{
    char line[MSGLEN];

    if (player->level >= PLAYER_MAXLEVEL)
        return;

    player->exp += amount;

    while (player->exp >= experience_to_level(player->level))
    {
        player->level += 1;

        attron(A_REVERSE | A_BLINK | A_BOLD | COLOR_PAIR(color_green));
        print_msg("You have gained a level!!");
        attrset(0);
        wait();

        snprintf(line, MSGLEN,
                 "You are now level %d.", player->level);
        print_msg(line);
        wait();
        clear_msg();

        player->mob->attr[ATTR_HP] += 10 + 2 * player->level;
        player->mob->attr[ATTR_MINDAM] += 1;
        player->mob->attr[ATTR_ATTACK] += 5;
        player->mob->attr[ATTR_DODGE] += 5;
    }

    return;
}
ssize_t
writev(int fd, const struct iovec *vector, int count) 
{
  ssize_t retval;

#ifdef X_BUF
  print_trace ("%*swritev(%d, {", indent, "", fd);
  for (int i=0; i<count; i++) {
    print_msg ("{\"%s\", %d}%s", 
	       vector[i].iov_base, 
	       vector[i].iov_len,
	       i==count-1 ? "" : ", ");
  }
  print_msg ("}, %d)=...\n", count);
#else
  print_trace ("%*swritev(%d, %p, %d)=...\n", indent, "",
	       fd, vector, count);
#endif
  indent+=2;

  /* call the real writev function */
  retval = real_writev (fd, vector, count);

  indent-=2;
  print_trace ("%*swritev(%d, %p, %d)=%d\n", indent, "", 
	       fd, vector, count, retval);

  return retval;
}
static int
select_format (const char * optstr, int dir)
{
/*
 * Handling of the -f command line option (force input format).
 *
 * Empty or "?" shows the supported format names.
 */
  int i;

  if ((!strcmp(optstr, "?")) || (*optstr == '\0'))
    {
      print_msg (STARTM, "\nSupported format names are:\n\n");
      for (i = 0; format_a[i].name != NULL; i++)
        if (dir & format_a[i].dir)
          print_msg (CONTM, "%s ", format_a[i].name);
      print_msg (ENDM, "\n");
      exit (0);
    }

  for (i = 0; format_a[i].name != NULL; i++)
    if ((format_a[i].dir & dir) && (!strcasecmp(format_a[i].name, optstr)))
      return format_a[i].fmt;

  print_msg (ERRORM, "Unsupported format name '%s'!\n", optstr);
  exit (E_USAGE);
}
static fctypes_t
select_container (const char * optstr)
{
/*
 * Handling of the -F command line option (force container format).
 *
 * Empty or "?" shows the supported container format names.
 */
  int i;

  if ((!strcmp(optstr, "?")) || (*optstr == '\0'))
    {
      print_msg (STARTM, "\nSupported container format names are:\n\n");
      for (i = 0; container_a[i].name != NULL; i++)
        print_msg (CONTM, "%s ", container_a[i].name);
      print_msg (ENDM, "\n");
      exit (0);
    }

  for (i = 0; container_a[i].name != NULL; i++)
    if (!strcasecmp(container_a[i].name, optstr))
      return container_a[i].type;

  print_msg (ERRORM, "Unsupported container format name '%s'!\n", optstr);
  exit (E_USAGE);
}
Example #8
0
void free(void* p, heap* h) 
{
    // Exit gracefully for null pointers.
    if (p == NULL)
        return;

    // Get the header and footer associated with this pointer.
    header *head = (header*) ((u32int) p - sizeof (header));
    footer *foot = (footer*) ((u32int) head + head->size - sizeof (footer));

    // Sanity checks.
    if(!(head->magic == HEAP_MAGIC && foot->magic == HEAP_MAGIC))
    {
        print_msg("Memory error\n");
        return;
    }

    // Make us a hole.
    head->is_hole = 1;

    // Do we want to add this head into the 'free holes' index?
    char do_add = 1;

    // Unify left
    // If the thing immediately to the left of us is a foot...
    footer *test_foot = (footer*) ((u32int) head - sizeof (footer));
    if (test_foot->magic == HEAP_MAGIC && test_foot->head->is_hole) {
        u32int cache_size = head->size; // Cache our current size.
        head = test_foot->head; // Rewrite our head with the new one.
        foot->head = head; // Rewrite our foot to point to the new head.
        head->size += cache_size; // Change the size.
        do_add = 0; // Since this head is already in the index, we don't want to add it again.
    }

    // Unify right
    // If the thing immediately to the right of us is a head...
    header *test_head = (header*) ((u32int) foot + sizeof (footer));
    if (test_head->magic == HEAP_MAGIC && test_head->is_hole) {
        head->size += test_head->size; // Increase our size.
        test_foot = (footer*) ((u32int) test_head + // Rewrite it's foot to point to our head.
                test_head->size - sizeof (footer));
        test_foot->head = head;
        // Find and remove this head from the index.
        u32int iterator = 0;
        while ((iterator < h->index.size) && (lookup_ordered_array(iterator, &h->index) != (u32int) test_head))
            iterator++;

        // Make sure we actually found the item.
        if(iterator >= h->index.size)
        {
            print_msg("Iterator behind heap size");
            return;
        }
        // Remove it.
        remove_ordered_array(iterator, &h->index);
    }

    if (do_add == 1)
        insert_ordered_array((u32int) head, &h->index);
}
Example #9
0
File: ji.c Project: placek/ji
static void
do_contact_input_string(struct xmpp *xmpp, struct contact *u, char *s)
{
  struct command *cmd;

  if (s[0] == 0)
    return;

  if (s[0] != '/') {
    if (u->jid[0])
      send_message(xmpp, u->type, u->jid, s);
    else
      xmpp_printf(xmpp, "%S", s);
    if (strcmp(u->type, "groupchat"))
      print_msg(0, u->jid, "<%s> %s\n", me, s);
    return;
  }
  for (cmd = commands; cmd->c; ++cmd)
    if (cmd->c == s[1] && cmd->fn != 0) {
      cmd->fn(xmpp, u, s);
      break;
    }
  if (!cmd->c) {
    send_message(xmpp, u->type, u->jid, s);
    if (strcmp(u->type, "groupchat"))
      print_msg(0, u->jid, "<%s> %s\n", me, s);
  }
}
Example #10
0
/* Returns pointer to a statically allocated buffer or NULL on error */
static const char *
parse_val(const char *str)
{
	static char buf[VAL_LEN_MAX + 1];
	char *p = buf;
	int quote = (*str++ == '"') ? 2 : 1;
	int slash = 0;

	/* parse all in currect quotes */
	while(*str != '\0' && quote != 0)
	{
		if(slash == 1)
		{
			*p++ = *str++;
			slash = 0;
		}
		else if(*str == '\\')
		{
			slash = 1;
		}
		else if(*str == '\'' && quote == 0)
		{
			quote = 1;
		}
		else if(*str == '\'' && quote == 1)
		{
			quote = 0;
		}
		else if(*str == '"' && quote == 0)
		{
			quote = 2;
		}
		else if(*str == '"' && quote == 2)
		{
			quote = 0;
		}
		else
		{
			*p++ = *str;
		}
		str++;
	}

	/* report an error if input is invalid */
	if(*str != '\0' || quote != 0)
	{
		if(quote != 0)
			print_msg(1, "Incorrect value", "unclosed quote");
		else
			print_msg(1, "Incorrect value", "trailing characters");
		return NULL;
	}

	*p = '\0';
	return buf;
}
Example #11
0
File: tools.c Project: dimkr/beaver
void conv_mac_to_dos (void)
{
  gint CurrentPage, res;
  
  CurrentPage = gtk_notebook_get_current_page (GTK_NOTEBOOK(MainNotebook));
  res = replace_all (CurrentPage, TRUE, FALSE, 0, "\r", "\r\n");
  if (!res)
    print_msg ("This file is already DOS formated...");
  else
    print_msg ("File converted from MAC to DOS Format...");
}
Example #12
0
void
parse_message(unsigned char type, char *buf, int size)
{
    char *msgt;
    int i;
    struct iocblk *iocp;
    struct buffer *bp = Pty.inbuff;


    print_msg(type, (unsigned char *) buf, size);

    if (size > 0) {
	switch (Pty.state) {
	case PTY_CLOSED:
	case PTY_OPERRONLY:
	    SET_EVENT(EV_UP, EV_UPOPEN, 0, 0);
	    break;
	}
    }
    else if (size == -1) {
	sysmessage(MSG_WARNING, "PARSE: Message data size == -1 \n");
	return;
    }

    switch (type) {
    case M_DATA:
# ifdef TSR_MEASURE
	devreads++;
	devrbytes += size;
# endif
	if (size == 0) {
	    SET_EVENT(EV_UP, EV_UPCLOSE, 0, 0);
	}
	else {
	    COPY_TO_BUFFER(bp, buf, size);
	    SET_EVENT(EV_UP, EV_UPDATA, 0, 0);
	}
	break;

    case M_IOCTL:
	iocp = (struct iocblk *) &buf[0];
	parse_ioctl(iocp->ioc_cmd, (void *) &buf[sizeof(struct iocblk)]);
	break;

    case M_FLUSH:
	parse_msgflush((int) buf[0]);
	break;

    default:
	sysmessage(MSG_DEBUG, "Unsupported stream message: %d\n", type);
	print_msg(type, (unsigned char *) buf, size);
	break;
    }
}
Example #13
0
int init_save(char *file)
{
    int fd=-1;
    fd=open(file,O_RDWR | O_CREAT | O_TRUNC | O_LARGEFILE);
    if(fd==-1)
    {
        print_msg("[%s,%d]", __FILE__, __LINE__);
        exit(-1);
    }
    print_msg("open write file ok\n");
    return fd;
}
Example #14
0
static void print_usage()
{
  print_msg(
    "Usage:\n"
    "    esmerge <video-file> <audio-file> <output-file>\n"
    "\n"
    );
  REPORT_VERSION("esmerge");
  print_msg(
    "\n"
    "  Merge the contents of two Elementary Stream (ES) files, one containing\n"
    "  video data, and the other audio, to produce an output file containing\n"
    "  Transport Stream (TS).\n"
    "\n"
    "Files:\n"
    "  <video-file>  is the ES file containing video.\n"
    "  <audio-file>  is the ES file containing audio.\n"
    "  <output-file> is the resultant TS file.\n"
    "\n"
    "Switches:\n"
    "  -err stdout       Write error messages to standard output (the default)\n"
    "  -err stderr       Write error messages to standard error (Unix traditional)\n"
    "  -quiet, -q        Only output error messages.\n"
    "  -verbose, -v      Output information about each audio/video frame.\n"
    "  -x                Output diagnostic information.\n"
    "\n"
    "  -h264             The video stream is H.264 (the default)\n"
    "  -avs              The video stream is AVS\n"
    "\n"
    "  -vidrate <hz>     Video frame rate in Hz - defaults to 25Hz.\n"
    "\n"
    "  -rate <hz>        Audio sample rate in Hertz - defaults to 44100, i.e., 44.1KHz.\n"
    "  -cd               Equivalent to -rate 44100 (CD rate), the default.\n"
    "  -dat              Equivalent to -rate 48000 (DAT rate).\n"
    "\n"
    "  -adts             The audio stream is ADTS (the default)\n"
    "  -l2               The audio stream is MPEG layer 2 audio\n"
    "  -mp2adts          The audio stream is MPEG-2 style ADTS regardless of ID bit\n"
    "  -mp4adts          The audio stream is MPEG-4 style ADTS regardless of ID bit\n"
    "  -ac3              The audio stream is Dolby AC-3 in ATSC\n"
    "\n"
    "  -patpmtfreq <f>    PAT and PMT will be inserted every <f> video frames. \n"
    "                     by default, f = 0 and PAT/PMT are inserted only at  \n"
    "                     the start of the output stream.\n"
    "\n"
    "Limitations\n"
    "===========\n"
    "For the moment, the video input must be H.264 or AVS, and the audio input\n"
    "ADTS, AC-3 ATSC or MPEG layer 2. Also, the audio is assumed to have a\n"
    "constant number of samples per frame.\n"
    );
}
Example #15
0
/* size must be >=2. No checks for s=NULL, size<2 or stream=NULL.  B.A. */
char *fgets_new(struct prog_info *pi, char *s, int size, FILE *stream)
{
	int c;
	char *ptr=s;
	do {
		if((c=fgetc(stream))==EOF || IS_ENDLINE(c)) 	// Terminate at chr$ 10,12,13,0 and EOF
			break;
        /*
        ** concatenate lines terminated with \ only...
        */
        if (c == '\\')
        {
            /* only newline and cr may follow... */
            if((c=fgetc(stream))==EOF)
                break;

            if(!IS_ENDLINE(c)) 	            // Terminate at chr$ 10,12,13,0 and EOF
            {
                *ptr++ = '\\';              // no concatenation, insert it
            }
            else
            {
                // mit be additional LF (DOS)
                c=fgetc(stream);
                if (IS_ENDLINE(c))
                    c=fgetc(stream);

                if (c == EOF)
                    break;
            }
        }

		*ptr++=c;
	} while(--size);
	if((c==EOF) && (ptr==s))				// EOF and no chars read -> that's all folks
		return NULL;
	if(!size) {
		print_msg(pi, MSGTYPE_ERROR, "Line to long");
		return NULL;
	}
	*ptr=0;
	if(c==12)						// Check for Formfeed (Bug [1462886])
		print_msg(pi, MSGTYPE_WARNING, "Found Formfeed char. Please remove it.");
	if(c==13) { 						// Check for CR LF sequence (DOS/ Windows line termination)
		if((c=fgetc(stream)) != 10) {
			ungetc(c,stream);
			print_msg(pi, MSGTYPE_WARNING, "Found CR (0x0d) without LF (0x0a). Please add a LF.");
		} 
	}
	return s;
}
Example #16
0
File: tools.c Project: dimkr/beaver
void print_buffer (void)
{
  FILE *File;
  gint CurrentPage;
  char *TempName, *PrintCmd;

  if (!OpenedFilesCnt)
    return;
  CurrentPage = gtk_notebook_get_current_page (GTK_NOTEBOOK(MainNotebook));
  if (!gtk_text_get_length (GTK_TEXT(FPROPS(CurrentPage, Text))))
    {
      print_msg ("Nothing to print !");
      return;
    }
  if (!FPROPS(CurrentPage, Changed[0]))
    {
      PrintCmd = g_strconcat (get_string_conf ("General/Misc/PrintCommand"),
			      " \"", FPROPS(CurrentPage, Name), "\"", NULL);
      print_msg (g_strconcat ("File \"", FPROPS(CurrentPage, Name),
			      "\" is being printed...", NULL));
    }
  else
    {
      gchar *Buffer;
      
      TempName = g_strconcat
	(TEMP_DIR, TEMP_PREFIX, FPROPS(CurrentPage, BaseName), NULL);
      if (!(File = fopen (TempName, "w")))
	{
	  print_msg (g_strconcat ("Buffer \"", FPROPS(CurrentPage, BaseName),
				  "\" cannot be printed", NULL));
	  g_free (TempName);
	  return;
	}
      Buffer = gtk_editable_get_chars
	(GTK_EDITABLE(FPROPS(CurrentPage, Text)), 0, -1);
      fwrite (Buffer, gtk_text_get_length
	      (GTK_TEXT(FPROPS(CurrentPage, Text))), 1, File);
      g_free (Buffer);
      fclose (File);
      PrintCmd = g_strconcat(get_string_conf
			     ("General/Misc/PrintCommand"),
			     " \"", TempName,"\"", NULL);
      print_msg (g_strconcat ("Buffer \"", FPROPS(CurrentPage, BaseName),
			      "\" is being printed...", NULL));
      g_free (TempName);
    }
  if (system (PrintCmd))
    print_msg (g_strconcat ("Problem encountered while trying to print", NULL));
  g_free (PrintCmd);
}
/* initialize/clean up */
static int __init mod_sysstat_recoder_init(void){
	print_msg("initialize module");
	print_msg("period_in_msecs: %ld", period_in_msecs);

	/* initialize a list of measured data */
	snapshot_head = NULL;
	snapshot_tail = NULL;

	init_debugfs();
	
	mod_sysstat_collect_start();

	return 0;
}
Example #18
0
/*
 * Look for an initial 0x47 sync byte, and check for TS
 *
 * Returns 0 if nothing went wrong, 1 if something did.
 */
static int check_if_TS(int   input,
                       byte  cur_byte,
                       int   verbose,
                       int  *decided,
                       int  *result)
{
  int  ii;

  if (verbose)
    print_msg("Is it Transport Stream?\n");

  // It may be enough to look at the first byte of the stream
  if (cur_byte != 0x47)
  {
    if (verbose)
      fprint_msg("  First byte in file is 0x%02X not 0x47, so it is not\n",cur_byte);
    return 0;
  }

  // Transport Stream packets start with 0x47, so it's a good bet.
  if (verbose)
    print_msg("  First byte in file is 0x47, so it looks like Transport Stream\n");

  // To check a bit, we can try looking at every 188th byte
  if (verbose)
    print_msg("  Checking next 500 packets to see if they start 0x47\n");
  for (ii=0; ii<500; ii++)
  {
    byte buf[TS_PACKET_SIZE];
    int err = read_bytes(input,TS_PACKET_SIZE,buf);
    if (err)
    {
      fprint_err("### %s trying to read start of packet %d\n",
                 (err==EOF?"EOF":"Error"),ii+1);
      return 1;
    }
    if (buf[TS_PACKET_SIZE-1] != 0x47)
    {
      if (verbose)
        fprint_msg("  Packet %d does not start with 0x47 (%02x instead)\n",
                   ii+1,buf[TS_PACKET_SIZE-1]);
      return 0;
    }
  }
  if (verbose)
    print_msg("The checked packets all start with 0x47 - looks like TS\n");
  *decided = TRUE;
  *result  = STREAM_IS_TS;
  return 0;
}
static void
find_devname (char * devname, const char * num)
{
/*
 * OSS 4.0 the audio device numbering may be different from the
 * legacy /dev/dsp# numbering reported by /dev/sndstat. Try to find the
 * device name (devnode) that matches the given device number.
 *
 * Prior versions of ossplay simply used the the /dev/dsp# number.
 */
  int dev;
  int mixer_fd;
  oss_audioinfo ai;
  const char * devmixer;

  if ((devmixer = getenv("OSS_MIXERDEV")) == NULL)
     devmixer = "/dev/mixer";

  if (sscanf (num, "%d", &dev) != 1)
    {
      print_msg (ERRORM, "Invalid audio device number '%s'\n", num);
      exit (E_SETUP_ERROR);
    }

  if ((mixer_fd = open (devmixer, O_RDWR, 0)) == -1)
    {
      perror_msg (devmixer);
      print_msg (WARNM, "Warning: Defaulting to /dev/dsp%s\n", num);
      snprintf (devname, OSS_DEVNODE_SIZE, "/dev/dsp%s", num);
      return;
    }

  ai.dev = dev;

  if (ioctl (mixer_fd, SNDCTL_AUDIOINFO, &ai) == -1)
    {
      perror_msg ("SNDCTL_AUDIOINFO");
      print_msg (WARNM, "Warning: Defaulting to /dev/dsp%s\n", num);
      snprintf (devname, OSS_DEVNODE_SIZE, "/dev/dsp%s", num);
      close (mixer_fd);
      return;
    }

  strncpy (devname, ai.devnode, OSS_DEVNODE_SIZE);

  close (mixer_fd);
  return;
}
Example #20
0
/* INIT. */
int main(signed int argc,char **argv){
 signal(SIGINT,sig_handler);

 /* FOREGROUND OR BACKGROUND. */
 if(argc>1&&!strcasecmp(argv[1],"daemon"))daemon=1;

 /* BANNER. */
 else
  printf("\nDNSDBD[v"DNSDBD_VERSION"]: DNSDB spider daemon, by: v9@fakehalo."
  "us.\n(run \"%s daemon\", to place into the background)\n\n",argv[0]);

 /* FOREGROUND/BACKGROUND SWITCH. */
 switch((dpid=(daemon?fork():0))){
  case -1:
   print_msg(1,"fork() failed.");
   break;
  case 0:
   dnsdbd_init();
   _exit(0);
   break;
  default:
   printf("%d\n",dpid);
   break;
 }
 exit(0);
}
Example #21
0
static char *
fixfrag_i(const char *gfarm_url, char *pathname, char *gfarm_file, char *sec)
{
	char *e, *path;

	e = fixfrag_ii(pathname, gfarm_file, sec);
	if (e != NULL) {
		if (e != GFARM_ERR_ALREADY_EXISTS) {
			print_errmsg(gfarm_url, sec, e);
			if (e != GFARM_ERR_TEXT_FILE_BUSY)
				delete_invalid_file_or_directory(pathname);
		}
		/* display file name */
		if (list_local_file) {
			path = strdup(pathname);
			if (path != NULL) {
				if (split_file_and_section(path, NULL) == NULL)
					printf("%s\n", path);
				free(path);
			}
		}
	}
	else
		print_msg(gfarm_url, sec, "fixed");

	return (e);
}
Example #22
0
int ipcs_main(int argc UNUSED_PARAM, char **argv)
{
	int id = 0;
	unsigned flags = 0;
	unsigned opt;
	char *opt_i;
#define flag_print	(1<<0)
#define flag_msg	(1<<1)
#define flag_sem	(1<<2)
#define flag_shm	(1<<3)

	opt = getopt32(argv, "i:aqsmtcplu", &opt_i);
	if (opt & 0x1) { // -i
		id = xatoi(opt_i);
		flags |= flag_print;
	}
	if (opt & 0x2) flags |= flag_msg | flag_sem | flag_shm; // -a
	if (opt & 0x4) flags |= flag_msg; // -q
	if (opt & 0x8) flags |= flag_sem; // -s
	if (opt & 0x10) flags |= flag_shm; // -m
	if (opt & 0x20) format = TIME; // -t
	if (opt & 0x40) format = CREATOR; // -c
	if (opt & 0x80) format = PID; // -p
	if (opt & 0x100) format = LIMITS; // -l
	if (opt & 0x200) format = STATUS; // -u

	if (flags & flag_print) {
		if (flags & flag_shm) {
			print_shm(id);
			fflush_stdout_and_exit(EXIT_SUCCESS);
		}
		if (flags & flag_sem) {
			print_sem(id);
			fflush_stdout_and_exit(EXIT_SUCCESS);
		}
		if (flags & flag_msg) {
			print_msg(id);
			fflush_stdout_and_exit(EXIT_SUCCESS);
		}
		bb_show_usage();
	}

	if (!(flags & (flag_shm | flag_msg | flag_sem)))
		flags |= flag_msg | flag_shm | flag_sem;
	bb_putchar('\n');

	if (flags & flag_shm) {
		do_shm();
		bb_putchar('\n');
	}
	if (flags & flag_sem) {
		do_sem();
		bb_putchar('\n');
	}
	if (flags & flag_msg) {
		do_msg();
		bb_putchar('\n');
	}
	fflush_stdout_and_exit(EXIT_SUCCESS);
}
Example #23
0
static void print_send_msg(Message *Msg)
{
	printf("\n==================== 发送报文开始 =====================\n");
	print_msg(Msg);
	printf("====================== 发送报文结束 ======================\n");
	return; 
}
Example #24
0
static void print_recv_msg(Message *Msg)
{
	printf("===================== 银行返回报文开始 =====================\n");
	print_msg(Msg);
	printf("===================== 银行返回报文结束 ======================\n");
	return; 
}
Example #25
0
/* Handler for say command */
static pj_status_t say(pj_cli_cmd_val *cval)
{
    print_msg(("", "%.*s %.*s\r\n",
              (int)cval->argv[1].slen, cval->argv[1].ptr,
              (int)cval->argv[2].slen, cval->argv[2].ptr));
    return PJ_SUCCESS;
}
Example #26
0
GLvoid print_msg(GLfloat x, GLfloat y, char* s, GLfloat m)
{
	char* str_ret;
	int cap=0;
	int sl1=strlen(s);
	int d=2;
	
	if (m>10) d=3;

	char* bfr=ftoa(m,d);
	int il=strlen(bfr);

	cap=sl1+il+2;
	str_ret=new char[cap];
	
	ZeroMemory(str_ret,sizeof(char)*cap);
	strcat(str_ret,s);
	strcat(str_ret," ");
	strcat(str_ret,bfr);

	print_msg(x, y, str_ret);

	if (bfr!=NULL)
		delete[] bfr;
	if (str_ret!=NULL)
		delete[] str_ret;
}
Example #27
0
LRESULT CALLBACK quick_record_dlg(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{
	char str[255];
	print_msg(msg,lparam,wparam);
	switch(msg)
	{
	case WM_SHOWWINDOW:
		SetCapture(GetDlgItem(hwnd,IDCANCEL));
		SetCursor(LoadCursor(NULL,IDC_CROSS));
		break;
	case WM_INITDIALOG:
		break;
	case WM_COMMAND:
		switch(LOWORD(wparam)){
		case IDCANCEL:
			SetCursor(LoadCursor(NULL,IDC_ARROW));
			EndDialog(hwnd,0);
			break;
		}
		break;
	case WM_CLOSE:
	case WM_QUIT:
		SetCursor(LoadCursor(NULL,IDC_ARROW));
		EndDialog(hwnd,0);
		break;
	}
	return 0;
}
Example #28
0
// Check if conditions to finish test are met.
bool
Responder::test_finished(size_t success_count)
{
    if (success_count == _opt.end_test_after_success_count)
    {
        print_msg( (boost::format("\nTest complete after %d successes.") % success_count).str() );
        return true;
    }
    if (((_opt.delay_min <= _opt.delay_max) && (_delay >= _opt.delay_max)) ||
        ((_opt.delay_min > _opt.delay_max) && (_delay <= _opt.delay_max)))
    {
        print_msg("\nTest complete.");
        return true;
    }
    return false;
}
Example #29
0
File: tools.c Project: dimkr/beaver
void color_picker (void)
{
  GtkColorSelectionDialog *ColorWindow;

  if (ColorIsVisible) return;
  ColorWindow = (GtkColorSelectionDialog *)gtk_color_selection_dialog_new
    ("Color Picker");
  gtk_signal_connect (GTK_OBJECT(ColorWindow), "delete_event",
		      (GtkSignalFunc) color_picker_not_visible, NULL);
  gtk_signal_connect_object (GTK_OBJECT(ColorWindow), "delete_event",
			     (GtkSignalFunc) gtk_widget_destroy,
			     GTK_OBJECT(ColorWindow));
  gtk_signal_connect (GTK_OBJECT (ColorWindow), "destroy",
		      (GtkSignalFunc) color_picker_not_visible, NULL);
  gtk_signal_connect_object (GTK_OBJECT(ColorWindow), "destroy",
			     (GtkSignalFunc) gtk_widget_destroy,
			     GTK_OBJECT(ColorWindow));
  gtk_label_set_text (GTK_LABEL(GTK_BIN(ColorWindow -> ok_button) -> child),
		      "Insert");
  gtk_signal_connect_object (GTK_OBJECT(ColorWindow -> ok_button), "clicked",
			     (GtkSignalFunc)insert_color,
			     GTK_OBJECT(ColorWindow -> colorsel));
  gtk_signal_connect (GTK_OBJECT(ColorWindow -> cancel_button), "clicked",
		      (GtkSignalFunc)color_picker_not_visible, NULL);
  gtk_signal_connect_object (GTK_OBJECT(ColorWindow -> cancel_button),
			     "clicked",
			     (GtkSignalFunc)gtk_widget_destroy,
			     GTK_OBJECT(ColorWindow));
  gtk_widget_hide (ColorWindow -> help_button);
  ColorIsVisible = TRUE;
  gtk_widget_show (GTK_WIDGET(ColorWindow));
  ColorIsVisible = TRUE;
  print_msg ("Display Color Picker...");
}
static void __exit mod_sysstat_recoder_exit(void){
	mod_sysstat_collect_stop();
	teardown_debugfs();
	delete_all_sysinfo_snapshot();
	print_msg("unload");

}