Ejemplo n.º 1
0
void allocnf(void)
{
    int pl, i, j;
    /* payoff matrices, two players only here, init to pay 0        */
    T2ALLOC (nfpay, nstrats[1], nstrats[2], Payvec);
    for (i=0; i<nstrats[1]; i++)
	for (j=0; j<nstrats[2]; j++)
	    for (pl=1; pl < PLAYERS; pl++)
		nfpay[i][j][pl-1] = ratfromi(0);
    for (pl=0; pl < PLAYERS; pl++)    
	{
	movetuple[pl] = TALLOC (nisets[pl], Move);
	mixedstrat[pl] = TALLOC (nstrats[pl], Rat);
	}
}
Ejemplo n.º 2
0
void *talloc_realloc(TALLOC_CTX *t, void *ptr, size_t size)
#endif
{
	struct talloc_chunk *tc;
	void *new_ptr;

	/* size zero is equivalent to free() */
	if (!t || size == 0)
		return NULL;

	/* realloc(NULL) is equavalent to malloc() */
	if (ptr == NULL)
		return TALLOC(t, size);

	for (tc=t->list; tc; tc=tc->next) {
		if (tc->ptr == ptr) {
			new_ptr = SMB_REALLOC(ptr, size);
			if (new_ptr) {
				t->total_alloc_size += (size - tc->size);
				tc->size = size;
				tc->ptr = new_ptr;
			}
			return new_ptr;
		}
	}
	return NULL;
}
Ejemplo n.º 3
0
NTSTATUS rpccli_echo_data(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
		       uint32 size, char *in_data, char **out_data)
{
	prs_struct qbuf, rbuf;
	ECHO_Q_ECHO_DATA q;
	ECHO_R_ECHO_DATA r;
	BOOL result = False;

	ZERO_STRUCT(q);
	ZERO_STRUCT(r);

	/* Marshall data and send request */

        init_echo_q_echo_data(&q, size, in_data);

	CLI_DO_RPC( cli, mem_ctx, PI_ECHO, ECHO_DATA,
			q, r,
			qbuf, rbuf,
			echo_io_q_echo_data,
			echo_io_r_echo_data,
			NT_STATUS_UNSUCCESSFUL);

	result = True;

	if (out_data) {
		*out_data = TALLOC(mem_ctx, size);
		if (!*out_data) {
			return NT_STATUS_NO_MEMORY;
		}
		memcpy(*out_data, r.data, size);
	}

	return result ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
}
Ejemplo n.º 4
0
void *talloc_array(TALLOC_CTX *ctx, size_t el_size, unsigned int count)
#endif
{
        if (count >= MAX_TALLOC_SIZE/el_size) {
                return NULL;
        }
	return TALLOC(ctx, el_size * count);
}
Ejemplo n.º 5
0
void _echo_data(pipes_struct *p, ECHO_Q_ECHO_DATA *q_u, 
		ECHO_R_ECHO_DATA *r_u)
{
	DEBUG(10, ("_echo_data\n"));

	r_u->data = TALLOC(p->mem_ctx, q_u->size);
	r_u->size = q_u->size;
	memcpy(r_u->data, q_u->data, q_u->size);
}
Ejemplo n.º 6
0
void *talloc_memdup(TALLOC_CTX *t, const void *p, size_t size)
#endif
{
	void *newp = TALLOC(t,size);

	if (newp)
		memcpy(newp, p, size);

	return newp;
}
Ejemplo n.º 7
0
void *talloc_zero(TALLOC_CTX *t, size_t size)
#endif
{
	void *p = TALLOC(t, size);

	if (p)
		memset(p, '\0', size);

	return p;
}
Ejemplo n.º 8
0
void _source_data(pipes_struct *p, ECHO_Q_SOURCE_DATA *q_u, 
		  ECHO_R_SOURCE_DATA *r_u)
{
	uint32 i;

	DEBUG(10, ("_source_data\n"));

	r_u->data = TALLOC(p->mem_ctx, q_u->size);
	r_u->size = q_u->size;

	for (i = 0; i < r_u->size; i++)
		r_u->data[i] = i & 0xff;
}
Ejemplo n.º 9
0
struct two_pool *initlist(Node node)				/*;initlist*/
{
	/* Allocate a single list structure (struct two_pool), set its data to
	 * be a pointer to the node given, and set its link field to point
	 * to itself, since tree node lists are circular.
	 */
	struct two_pool *tmp;

	tmp = TALLOC();
	tmp->val.node = node;
	tmp->link = tmp;
	return(tmp);
}
Ejemplo n.º 10
0
char *unistr2_tdup(TALLOC_CTX *ctx, const UNISTR2 *str)
{
	char *s;
	int maxlen = (str->uni_str_len+1)*4;
	if (!str->buffer) {
		return NULL;
	}
	s = (char *)TALLOC(ctx, maxlen); /* convervative */
	if (!s) {
		return NULL;
	}
	pull_ucs2(NULL, s, str->buffer, maxlen, str->uni_str_len*2, STR_NOALIGN);
	return s;
}
Ejemplo n.º 11
0
static XmbufBufferInfo *read_buffer_info (Display *dpy, int nbufs)
{
    xMbufBufferInfo *netbuf = TALLOC (xMbufBufferInfo, nbufs);
    XmbufBufferInfo *bufinfo = NULL;
    long netbytes = nbufs * SIZEOF(xMbufBufferInfo);

    if (netbuf) {
	_XRead (dpy, (char *) netbuf, netbytes);

	bufinfo = TALLOC (XmbufBufferInfo, nbufs);
	if (bufinfo) {
	    register XmbufBufferInfo *c;
	    register xMbufBufferInfo *net;
	    register int i;

	    for (i = 0, c = bufinfo, net = netbuf; i < nbufs;
		 i++, c++, net++) {
		c->visualid = net->visualID;
		c->max_buffers = net->maxBuffers;
		c->depth = net->depth;
	    }
	}
	Xfree ((char *) netbuf);
    } else {				/* eat the data */
	while (netbytes > 0) {
	    char dummy[256];		/* stack size vs loops tradeoff */
	    long nbytes = sizeof dummy;

	    if (nbytes > netbytes) nbytes = netbytes;
	    _XRead (dpy, dummy, nbytes);
	    netbytes -= nbytes;
	}
    }

    return bufinfo;
}
Ejemplo n.º 12
0
 char *talloc_vasprintf(TALLOC_CTX *t, const char *fmt, va_list ap)
{	
	int len;
	char *ret;
	va_list ap2;
	
	VA_COPY(ap2, ap);

	len = vsnprintf(NULL, 0, fmt, ap2);

	ret = TALLOC(t, len+1);
	if (ret) {
		VA_COPY(ap2, ap);
		vsnprintf(ret, len+1, fmt, ap2);
	}

	return ret;
}
Ejemplo n.º 13
0
Equilibrium createEquilibrium(gmpt** A, gmpt* scfa, gmpt det, int* bascobas, int* whichvar, int n, int nrows, int ncols)
{
	Equilibrium eq;
	
	T2ALLOC (eq.A, n, n+2, gmpt);
	G2INIT (eq.A, n, n+2);
    eq.scfa = TALLOC (n+2, gmpt);
    eq.bascobas = TALLOC(2*n+1, int);
	eq.whichvar = TALLOC(2*n+1, int);
	
	int i, j;
	for(i = 0; i < n; ++i)
	{
		for(j = 0; j < n+2; ++j)
		{
			gset(eq.A[i][j], A[i][j]);
		}
	}
	
	for(i = 0; i < n+2; ++i)
	{
		gset(eq.scfa[i], scfa[i]);
	}
	
	for(i = 0; i < 2*n+1; ++i)
	{
		eq.bascobas[i] = bascobas[i];
		eq.whichvar[i] = whichvar[i];
	}
	ginit(eq.det);
	gset(eq.det, det);
	
	eq.lcpdim = n;
    eq.nrows = nrows;
    eq.ncols = ncols;
	
	return eq;
}
Ejemplo n.º 14
0
DATA_BLOB data_blob_talloc(TALLOC_CTX *mem_ctx, const void *p, size_t length)
{
	DATA_BLOB ret;

	if (!length) {
		ZERO_STRUCT(ret);
		return ret;
	}

	if (p) {
		ret.data = (uint8 *)TALLOC_MEMDUP(mem_ctx, p, length);
		if (ret.data == NULL)
			smb_panic("data_blob_talloc: TALLOC_MEMDUP failed.\n");
	} else {
		ret.data = (uint8 *)TALLOC(mem_ctx, length);
		if (ret.data == NULL)
			smb_panic("data_blob_talloc: talloc failed.\n");
	}

	ret.length = length;
	ret.free = NULL;
	return ret;
}
Ejemplo n.º 15
0
BOOL rename_share_filename(struct share_mode_lock *lck,
			const char *servicepath,
			const char *newname)
{
	size_t sp_len;
	size_t fn_len;
	size_t msg_len;
	char *frm = NULL;
	int i;

	if (!lck) {
		return False;
	}

	DEBUG(10, ("rename_share_filename: servicepath %s newname %s\n",
		servicepath, newname));

	/*
	 * rename_internal_fsp() and rename_internals() add './' to
	 * head of newname if newname does not contain a '/'.
	 */
	while (newname[0] && newname[1] && newname[0] == '.' && newname[1] == '/') {
		newname += 2;
	}

	lck->servicepath = talloc_strdup(lck, servicepath);
	lck->filename = talloc_strdup(lck, newname);
	if (lck->filename == NULL || lck->servicepath == NULL) {
		DEBUG(0, ("rename_share_filename: talloc failed\n"));
		return False;
	}
	lck->modified = True;

	sp_len = strlen(lck->servicepath);
	fn_len = strlen(lck->filename);

	msg_len = MSG_FILE_RENAMED_MIN_SIZE + sp_len + 1 + fn_len + 1;

	/* Set up the name changed message. */
	frm = TALLOC(lck, msg_len);
	if (!frm) {
		return False;
	}

	SDEV_T_VAL(frm,0,lck->dev);
	SINO_T_VAL(frm,8,lck->ino);

	DEBUG(10,("rename_share_filename: msg_len = %u\n", (unsigned int)msg_len ));

	safe_strcpy(&frm[16], lck->servicepath, sp_len);
	safe_strcpy(&frm[16 + sp_len + 1], lck->filename, fn_len);

	/* Send the messages. */
	for (i=0; i<lck->num_share_modes; i++) {
		struct share_mode_entry *se = &lck->share_modes[i];
		if (!is_valid_share_mode_entry(se)) {
			continue;
		}
		/* But not to ourselves... */
		if (procid_is_me(&se->pid)) {
			continue;
		}

		DEBUG(10,("rename_share_filename: sending rename message to pid %u "
			"dev %x, inode  %.0f sharepath %s newname %s\n",
			(unsigned int)procid_to_pid(&se->pid),
			(unsigned int)lck->dev, (double)lck->ino,
			lck->servicepath, lck->filename ));

		become_root();
		message_send_pid(se->pid, MSG_SMB_FILE_RENAME,
				frm, msg_len, True);
		unbecome_root();
	}

	return True;
}
Ejemplo n.º 16
0
int main(int argc, char **argv)
{
	TALLOC_CTX *ctx;
	struct samu *out = NULL;
	struct samu *in = NULL;
	NTSTATUS rv;
	int i;
	struct timeval tv;
	BOOL error = False;
	struct passwd *pwd;
	uint8 *buf;
	uint32 expire, min_age, history;
	struct pdb_methods *pdb;
	poptContext pc;
	static const char *backend = NULL;
	static const char *unix_user = "******";
	struct poptOption long_options[] = {
		{"username", 'u', POPT_ARG_STRING, &unix_user, 0, "Unix user to use for testing", "USERNAME" },
		{"backend", 'b', POPT_ARG_STRING, &backend, 0, "Backend to use if not default", "BACKEND[:SETTINGS]" },
		POPT_AUTOHELP
		POPT_COMMON_SAMBA
		POPT_TABLEEND
	};

	load_case_tables();

	pc = poptGetContext("vfstest", argc, (const char **) argv,
			    long_options, 0);

	poptSetOtherOptionHelp(pc, "backend[:settings] username");
	
	while(poptGetNextOpt(pc) != -1);

	poptFreeContext(pc);

	/* Load configuration */
	lp_load(dyn_CONFIGFILE, False, False, True, True);
	setup_logging("pdbtest", True);

	if (backend == NULL) {
		backend = lp_passdb_backend();
	}

	rv = make_pdb_method_name(&pdb, backend);
	if (NT_STATUS_IS_ERR(rv)) {
		fprintf(stderr, "Error initializing '%s': %s\n", backend, get_friendly_nt_error_msg(rv));
		exit(1);
	}
	
	ctx = talloc_init("PDBTEST");
	
	if (!(out = samu_new(ctx))) {
		fprintf(stderr, "Can't create samu structure.\n");
		exit(1);
	}
	
	if ((pwd = getpwnam_alloc(ctx, unix_user)) == NULL) {
		fprintf(stderr, "Error getting user information for %s\n", unix_user);
		exit(1);
	}
	
	samu_set_unix(out, pwd);

	pdb_set_profile_path(out, "\\\\torture\\profile", PDB_SET);
	pdb_set_homedir(out, "\\\\torture\\home", PDB_SET);
	pdb_set_logon_script(out, "torture_script.cmd", PDB_SET);

	pdb_get_account_policy(AP_PASSWORD_HISTORY, &history);
	if (history * PW_HISTORY_ENTRY_LEN < NT_HASH_LEN) {
		buf = (uint8 *)TALLOC(ctx, NT_HASH_LEN);
	} else {
		buf = (uint8 *)TALLOC(ctx, history * PW_HISTORY_ENTRY_LEN);
	}

	/* Generate some random hashes */
	GetTimeOfDay(&tv);
	srand(tv.tv_usec);
	for (i = 0; i < NT_HASH_LEN; i++) {
		buf[i] = (uint8) rand();
	}
	pdb_set_nt_passwd(out, buf, PDB_SET);
	for (i = 0; i < LM_HASH_LEN; i++) {
		buf[i] = (uint8) rand();
	}
	pdb_set_lanman_passwd(out, buf, PDB_SET);
	for (i = 0; i < history * PW_HISTORY_ENTRY_LEN; i++) {
		buf[i] = (uint8) rand();
	}
	pdb_set_pw_history(out, buf, history, PDB_SET);

	pdb_get_account_policy(AP_MAX_PASSWORD_AGE, &expire);
	pdb_get_account_policy(AP_MIN_PASSWORD_AGE, &min_age);
	pdb_set_pass_last_set_time(out, time(NULL), PDB_SET);
	
	if (expire == 0 || expire == (uint32)-1) {
		pdb_set_pass_must_change_time(out, get_time_t_max(), PDB_SET);
	} else {
		pdb_set_pass_must_change_time(out, time(NULL)+expire, PDB_SET);
	}

	if (min_age == (uint32)-1) {
		pdb_set_pass_can_change_time(out, 0, PDB_SET);
	} else {
		pdb_set_pass_can_change_time(out, time(NULL)+min_age, PDB_SET);
	}
	
	/* Create account */
	if (!NT_STATUS_IS_OK(rv = pdb->add_sam_account(pdb, out))) {
		fprintf(stderr, "Error in add_sam_account: %s\n", 
				get_friendly_nt_error_msg(rv));
		exit(1);
	}

	if (!(in = samu_new(ctx))) {
		fprintf(stderr, "Can't create samu structure.\n");
		exit(1);
	}
	
	/* Get account information through getsampwnam() */
	if (NT_STATUS_IS_ERR(pdb->getsampwnam(pdb, in, out->username))) {
		fprintf(stderr, "Error getting sampw of added user %s.\n",
				out->username);
		if (!NT_STATUS_IS_OK(rv = pdb->delete_sam_account(pdb, out))) {
			fprintf(stderr, "Error in delete_sam_account %s\n", 
					get_friendly_nt_error_msg(rv));
		}
		TALLOC_FREE(ctx);
	}
	
	/* Verify integrity */
	if (samu_correct(out, in)) {
		printf("User info written correctly\n");
	} else {
		printf("User info NOT written correctly\n");
		error = True;
	}
	
	/* Delete account */
	if (!NT_STATUS_IS_OK(rv = pdb->delete_sam_account(pdb, out))) {
		fprintf(stderr, "Error in delete_sam_account %s\n", 
					get_friendly_nt_error_msg(rv));
	}

	pdb->setsampwent(pdb, False, 0);
	while (NT_STATUS_IS_OK(pdb->getsampwent(pdb, out))) {
		if (pdb_get_username(out) == NULL) {
			fprintf(stderr, "Got bad username through getsampwent()\n");
			error = True;
			break;
		}
		if (NT_STATUS_IS_ERR(pdb->getsampwnam(pdb, in, pdb_get_username(out)))) {
			fprintf(stderr, "Error getting samu through getsampwnam() of an account we got through getsampwent!\n");
			error = True;
			continue;
		}
		if (!samu_correct(out, in)) {
			printf("Record gotten through getsampwnam() differs from same record through getsampwent()\n");
		}
	}
	pdb->endsampwent(pdb);
	
	TALLOC_FREE(ctx);

	if (error) {
		return 1;
	}
	return 0;
}
Ejemplo n.º 17
0
static void print_notify_send_messages_to_printer(struct messaging_context *msg_ctx,
						  const char *printer,
						  unsigned int timeout)
{
	char *buf;
	struct notify_queue *pq, *pq_next;
	size_t msg_count = 0, offset = 0;
	size_t num_pids = 0;
	size_t i;
	pid_t *pid_list = NULL;
	struct timeval end_time = timeval_zero();

	/* Count the space needed to send the messages. */
	for (pq = notify_queue_head; pq; pq = pq->next) {
		if (strequal(printer, pq->msg->printer)) {
			if (!flatten_message(pq)) {
				DEBUG(0,("print_notify_send_messages: Out of memory\n"));
				talloc_free_children(send_ctx);
				num_messages = 0;
				return;
			}
			offset += (pq->buflen + 4);
			msg_count++;
		}	
	}
	offset += 4; /* For count. */

	buf = (char *)TALLOC(send_ctx, offset);
	if (!buf) {
		DEBUG(0,("print_notify_send_messages: Out of memory\n"));
		talloc_free_children(send_ctx);
		num_messages = 0;
		return;
	}

	offset = 0;
	SIVAL(buf,offset,msg_count);
	offset += 4;
	for (pq = notify_queue_head; pq; pq = pq_next) {
		pq_next = pq->next;

		if (strequal(printer, pq->msg->printer)) {
			SIVAL(buf,offset,pq->buflen);
			offset += 4;
			memcpy(buf + offset, pq->buf, pq->buflen);
			offset += pq->buflen;

			/* Remove from list. */
			DLIST_REMOVE(notify_queue_head, pq);
		}
	}

	DEBUG(5, ("print_notify_send_messages_to_printer: sending %lu print notify message%s to printer %s\n", 
		  (unsigned long)msg_count, msg_count != 1 ? "s" : "", printer));

	/*
	 * Get the list of PID's to send to.
	 */

	if (!print_notify_pid_list(printer, send_ctx, &num_pids, &pid_list))
		return;

	if (timeout != 0) {
		end_time = timeval_current_ofs(timeout, 0);
	}

	for (i = 0; i < num_pids; i++) {
		messaging_send_buf(msg_ctx,
				   pid_to_procid(pid_list[i]),
				   MSG_PRINTER_NOTIFY2 | MSG_FLAG_LOWPRIORITY,
				   (uint8 *)buf, offset);

		if ((timeout != 0) && timeval_expired(&end_time)) {
			break;
		}
	}
}
Ejemplo n.º 18
0
bool pdb_set_plaintext_passwd(struct samu *sampass, const char *plaintext)
{
	uchar new_lanman_p16[LM_HASH_LEN];
	uchar new_nt_p16[NT_HASH_LEN];

	if (!plaintext)
		return False;

	/* Calculate the MD4 hash (NT compatible) of the password */
	E_md4hash(plaintext, new_nt_p16);

	if (!pdb_set_nt_passwd (sampass, new_nt_p16, PDB_CHANGED)) 
		return False;

	if (!E_deshash(plaintext, new_lanman_p16)) {
		/* E_deshash returns false for 'long' passwords (> 14
		   DOS chars).  This allows us to match Win2k, which
		   does not store a LM hash for these passwords (which
		   would reduce the effective password length to 14 */

		if (!pdb_set_lanman_passwd (sampass, NULL, PDB_CHANGED)) 
			return False;
	} else {
		if (!pdb_set_lanman_passwd (sampass, new_lanman_p16, PDB_CHANGED)) 
			return False;
	}

	if (!pdb_set_plaintext_pw_only (sampass, plaintext, PDB_CHANGED)) 
		return False;

	if (!pdb_set_pass_last_set_time (sampass, time(NULL), PDB_CHANGED))
		return False;

	/* Store the password history. */
	if (pdb_get_acct_ctrl(sampass) & ACB_NORMAL) {
		uchar *pwhistory;
		uint32 pwHistLen;
		pdb_get_account_policy(AP_PASSWORD_HISTORY, &pwHistLen);
		if (pwHistLen != 0){
			uint32 current_history_len;
			/* We need to make sure we don't have a race condition here - the
			   account policy history length can change between when the pw_history
			   was first loaded into the struct samu struct and now.... JRA. */
			pwhistory = (uchar *)pdb_get_pw_history(sampass, &current_history_len);

			if (current_history_len != pwHistLen) {
				/* After closing and reopening struct samu the history
					values will sync up. We can't do this here. */

				/* current_history_len > pwHistLen is not a problem - we
					have more history than we need. */

				if (current_history_len < pwHistLen) {
					/* Ensure we have space for the needed history. */
					uchar *new_history = (uchar *)TALLOC(sampass,
								pwHistLen*PW_HISTORY_ENTRY_LEN);
					if (!new_history) {
						return False;
					}

					/* And copy it into the new buffer. */
					if (current_history_len) {
						memcpy(new_history, pwhistory,
							current_history_len*PW_HISTORY_ENTRY_LEN);
					}
					/* Clearing out any extra space. */
					memset(&new_history[current_history_len*PW_HISTORY_ENTRY_LEN],
						'\0', (pwHistLen-current_history_len)*PW_HISTORY_ENTRY_LEN);
					/* Finally replace it. */
					pwhistory = new_history;
				}
			}
			if (pwhistory && pwHistLen){
				/* Make room for the new password in the history list. */
				if (pwHistLen > 1) {
					memmove(&pwhistory[PW_HISTORY_ENTRY_LEN],
						pwhistory, (pwHistLen -1)*PW_HISTORY_ENTRY_LEN );
				}
				/* Create the new salt as the first part of the history entry. */
				generate_random_buffer(pwhistory, PW_HISTORY_SALT_LEN);

				/* Generate the md5 hash of the salt+new password as the second
					part of the history entry. */

				E_md5hash(pwhistory, new_nt_p16, &pwhistory[PW_HISTORY_SALT_LEN]);
				pdb_set_pw_history(sampass, pwhistory, pwHistLen, PDB_CHANGED);
			} else {
				DEBUG (10,("pdb_get_set.c: pdb_set_plaintext_passwd: pwhistory was NULL!\n"));
			}
		} else {
			/* Set the history length to zero. */
			pdb_set_pw_history(sampass, NULL, 0, PDB_CHANGED);
		}
	}

	return True;
}
Ejemplo n.º 19
0
void setrsfcomplconstr (int paytopl, Rat ** intoM,
                        int rowoffset, int coloffset, Bool negpaymatrix,
                        Rat * rhsvec, Bool negrhs)
{
    int othpl = 3 - paytopl;   /* other player         */
    int i,j,k, a;
    Rat s;
    Rat * tmprow;   /* temporary row for triple matrix product comptn   */
    tmprow = TALLOC( nseqs[othpl] , Rat);

    /* first blockrow  of dim   redsfdim[paytopl]       */
    for (i = 0; i < redsfdim[paytopl]; i++)
    {
        /* compute  tmprow (with index  j ) as
         * if  paytopl==1:  row  i  of  K\T A,
         * if  paytopl==2:  row  i  of  L\T B\T
         */
        for (j = 0; j < nseqs[othpl]; j++)
        {
            s = ratfromi(0);
            for (k = 0; k < nseqs[paytopl]; k++)
                /* a = entry of  K\T  resp. L\T         */
                if ((a = realplfromredsf[paytopl][k][i] ) != 0)
                    s = ratadd( s, ratmult( ratfromi(a),
                                            (paytopl==1) ? sfpay[k][j][0] : sfpay[j][k][1] )) ;
            tmprow[j] = s;
        }
        /* compute i,k entry of
         * if  paytopl==1:  K\T A L   = Ahat
         * if  paytopl==2:  L\T B\T K = Bhat \T
         * comments from now only for  paytopl==1
         */
        for (k = 0; k < redsfdim[othpl]; k++)
        {
            s = ratfromi(0);
            for (j = 0; j < nseqs[othpl]; j++)
                if ( (a = realplfromredsf [othpl][j][k] ) != 0)
                    s = ratadd( s, ratmult( ratfromi(a), tmprow[j] )) ;
            /* fill matrix entry with   -Ahat   */
            intoM [ rowoffset + i] [ coloffset + k ] =
                negpaymatrix ? ratneg(s) : s ;
        }
        /* set matrix entry for  Ehat\T         */
        for (j = 0; j < irreddim[paytopl]; j++)
        {
            s = ratfromi( redsfconstr [paytopl][j][i] );
            intoM [ rowoffset + i] [ coloffset + redsfdim[othpl] + j] =
                negpaymatrix ? s : ratneg(s) ;
        }
        /* set LCP rhs entry  i  of  K\T A l = ahat     */
        s = ratfromi(0);
        for (j = 0; j < nseqs[othpl]; j++)
            s = ratadd( s, ratmult( tmprow[j],
                                    ratfromi ( realplconst [othpl] [j] ) ) ) ;
        rhsvec[i] = negrhs ? ratneg(s) : s ;
    }
    
    /* second blockrow  of dim   irreddim [othpl]       */
    for (i = 0; i < irreddim [othpl]; i++)
    {
        /* set LCP matrix entry for  -Fhat              */
        for (j = 0; j < redsfdim[othpl]; j++)
        {
            s = ratfromi( redsfconstr [othpl][i][j] );
            intoM [ rowoffset + redsfdim[paytopl] + i ] [ coloffset + j] =
                negpaymatrix ? ratneg(s) : s ;
        }
        /* set LCP rhs entry  i  of  -fhat              */
        s = ratfromi( redsfrhs [othpl][i] );
        rhsvec[ redsfdim[paytopl] + i] = negrhs ? s : ratneg(s) ;
    }
    free(tmprow);
}