Beispiel #1
0
void gauss(int i, int j)
{
  printab();
  if(i+1<rows && j+1<cols)
    {
      if(notnull(i,j)==rows)
	gauss(i,j+1);
      else
	{
	  if(!tab[j+i*cols])
	    {
	      rowswap(i,notnull(i+1,j));
	      gauss(i,j);
	    }
	  else
	    if(notnull(i+1,j)!=rows)
	      {
		rowdux(i,j,notnull(i+1,j));
		gauss(i,j);
	      }
	    else
	      gauss(i+1,j+1);
	}
    }
}
Beispiel #2
0
int g3 (/*@null@*/ int *y)
{
  if (notnull (y))
    {
      return 0;
    }

  return *y;
}
Beispiel #3
0
int
writecontrolfile(struct letter *let)
{
    FILE *f;
    char ctrlfile[sizeof(DATAPFX)+6+1];
    int count;
    enum r_status status;

    /* after writing the data, write the control file
     */
    sprintf(ctrlfile, CTRLPFX "%s", let->qid);

    if ( (f=fopen(ctrlfile, "w")) != 0) {
	/* queue comments always come first.
	 */
	if (let->qcomment && let->qcomment[0])
	    fprintf(f, "%c%s\n", C_STATUS, let->qcomment);
	
	if (notnull(let->from)) {
	    if (let->from->domain && strlen(let->from->domain) > 0)
		fprintf(f, "%c%s\n", C_FROM, let->from->full);
	    else
		fprintf(f, "%c%s@%s\n",C_FROM,let->from->user,
				    let->env->localhost);
	}

	for (count=let->remote.count; count-- > 0; ) {
	    status = let->remote.to[count].status;
	    if (status == PENDING || status == ACCEPTED) {
		fprintf(f, "%c%s|%s\n", C_TO, let->remote.to[count].fullname,
					      let->remote.to[count].host);
	    }
	}

	if (let->mesgfrom)
	    fprintf(f, "%cF ;has from:\n", C_FLAGS);

	/* additional headers ALWAYS come at the end of the
	 * control message so we can cheat and simply spool them
	 * off the disk.
	 */
	if ( let->has_headers ) {
	    fprintf(f, "%cH ;has headers\n", C_FLAGS);
	    fprintf(f, "%c%c ;additional headers\n", C_HEADER, C_HEADER);
	    addheaders(f, let);
	}

	if ( ferror(f) == 0 && fclose(f) == 0)
	    return 1;
	syslog(LOG_ERR, "can't write to controlfile: %m");
	fclose(f);
    }
    syslog(LOG_ERR, "can't save to controlfile: %m");
    return 0;
}
Beispiel #4
0
int g2 (/*@null@*/ int *y)
{
  if (notnull (y))
    {
      return 0;
    }
  else
    {
      return *y;
    }
}
Beispiel #5
0
void
mboxfrom(FILE *f, struct letter *let)
{
    char date[80];

    if (let->mboxfrom) return;

    strftime(date, 80, "%a %b %d %H:%M:%S %Y", localtime(&let->posted));
    fprintf(f, "From %s %s\n", notnull(let->from) ? let->from->full
                                                  : "<>", date);
}
Beispiel #6
0
int test_magic_missile(void *state) {

	/* Try making a new game */
	cmdq_push(CMD_BIRTH_INIT);
	cmdq_push(CMD_BIRTH_RESET);
	cmdq_push(CMD_CHOOSE_RACE);
	cmd_set_arg_choice(cmdq_peek(), "choice", 4);

	cmdq_push(CMD_CHOOSE_CLASS);
	cmd_set_arg_choice(cmdq_peek(), "choice", 1);

	cmdq_push(CMD_ROLL_STATS);
	cmdq_push(CMD_NAME_CHOICE);
	cmd_set_arg_string(cmdq_peek(), "name", "Tyrion");

	cmdq_push(CMD_ACCEPT_CHARACTER);
	cmdq_execute(CMD_BIRTH);

	eq(player->is_dead, FALSE);
	cave_generate(&cave, player);
	on_new_level();
	notnull(cave);
	eq(player->chp, player->mhp);
	eq(player->food, PY_FOOD_FULL - 1);

	cmdq_push(CMD_STUDY);
	cmd_set_arg_choice(cmdq_peek(), "spell", 0);
	run_game_loop();
	cmdq_push(CMD_CAST);
	cmd_set_arg_choice(cmdq_peek(), "spell", 0);
	cmd_set_arg_target(cmdq_peek(), "target", 2);
	run_game_loop();
	noteq(player->csp, player->msp);

	ok;
}
static void raw_do_one(int lnr, const char *line)
{
	char local_addr[64], rem_addr[64];
	char *state_str, more[512];
	int num, local_port, rem_port, d, state, timer_run, uid, timeout;
#if ENABLE_FEATURE_IPV6
	struct sockaddr_in6 localaddr, remaddr;
	char addr6[INET6_ADDRSTRLEN];
	struct in6_addr in6;
#else
	struct sockaddr_in localaddr, remaddr;
#endif
	unsigned long rxq, txq, time_len, retr, inode;

	if (lnr == 0)
		return;

	more[0] = '\0';
	num = sscanf(line,
				 "%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %ld %512s\n",
				 &d, local_addr, &local_port,
				 rem_addr, &rem_port, &state,
				 &txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode, more);

	if (strlen(local_addr) > 8) {
#if ENABLE_FEATURE_IPV6
		sscanf(local_addr, "%08X%08X%08X%08X",
			   &in6.s6_addr32[0], &in6.s6_addr32[1],
			   &in6.s6_addr32[2], &in6.s6_addr32[3]);
		inet_ntop(AF_INET6, &in6, addr6, sizeof(addr6));
		inet_pton(AF_INET6, addr6, (struct sockaddr *) &localaddr.sin6_addr);
		sscanf(rem_addr, "%08X%08X%08X%08X",
			   &in6.s6_addr32[0], &in6.s6_addr32[1],
			   &in6.s6_addr32[2], &in6.s6_addr32[3]);
		inet_ntop(AF_INET6, &in6, addr6, sizeof(addr6));
		inet_pton(AF_INET6, addr6, (struct sockaddr *) &remaddr.sin6_addr);
		localaddr.sin6_family = AF_INET6;
		remaddr.sin6_family = AF_INET6;
#endif
	} else {
		sscanf(local_addr, "%X",
			   &((struct sockaddr_in *) &localaddr)->sin_addr.s_addr);
		sscanf(rem_addr, "%X",
			   &((struct sockaddr_in *) &remaddr)->sin_addr.s_addr);
		((struct sockaddr *) &localaddr)->sa_family = AF_INET;
		((struct sockaddr *) &remaddr)->sa_family = AF_INET;
	}

	if (num < 10) {
		bb_error_msg("warning, got bogus raw line");
		return;
	}
	state_str = itoa(state);

#if ENABLE_FEATURE_IPV6
# define notnull(A) (((A.sin6_family == AF_INET6) &&            \
					 ((A.sin6_addr.s6_addr32[0]) ||            \
					  (A.sin6_addr.s6_addr32[1]) ||            \
					  (A.sin6_addr.s6_addr32[2]) ||            \
					  (A.sin6_addr.s6_addr32[3]))) ||          \
					((A.sin6_family == AF_INET) &&             \
					 ((struct sockaddr_in *) &A)->sin_addr.s_addr))
#else
# define notnull(A) (A.sin_addr.s_addr)
#endif
	if ((notnull(remaddr) && (flags & NETSTAT_CONNECTED))
	 || (!notnull(remaddr) && (flags & NETSTAT_LISTENING))
	) {
		snprint_ip_port(local_addr, sizeof(local_addr),
						(struct sockaddr *) &localaddr, local_port,
						"raw", flags & NETSTAT_NUMERIC);

		snprint_ip_port(rem_addr, sizeof(rem_addr),
						(struct sockaddr *) &remaddr, rem_port,
						"raw", flags & NETSTAT_NUMERIC);

		printf("raw   %6ld %6ld %-23s %-23s %-12s\n",
			   rxq, txq, local_addr, rem_addr, state_str);
	}
}