Esempio n. 1
0
/*
 * s must be terminated by a \0
 */
struct form* make_form(struct form *f, char *s)
{
	unsigned int l = form_string_length(s);

	memcpy(&(f->text), s, l);
	memcpy(&(f->len), s, l);
	return f;
}
Esempio n. 2
0
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "../libc.rogue/include/stdlib.h"
#include "../libc.rogue/include/string.h"
#include "form.h"
#include "routines.h"
#include "opcodes.h"

static int write_operation(unsigned char *r, struct operator *oper, unsigned char *prefix)
{
	unsigned char *operand1 = (unsigned char*)oper->oper->operands->operand1;
	unsigned char *operand2 = (unsigned char*)oper->oper->operands->operand2;
	int op1sz = form_string_length(operand1);
	int op2sz = form_string_length(operand2);
	int sz = form_string_length(prefix) + op1sz 
						+ op2sz 
						+ 1;
	/* null terminate */
	*(r+sz-1) = '\0';

	/* copy operator prefix string to r */

	memcpy(r, prefix, 3);
	int i = 3;	

	/* copy operand1 string to r */

	do