h48

A prototype for an optimal Rubik's cube solver, work in progress.
git clone https://git.tronto.net/h48
Download | Log | Files | Refs | README | LICENSE

io_trans.h (420B)


      1 STATIC uint8_t readtrans(const char *);
      2 STATIC void writetrans(uint8_t, char *);
      3 
      4 STATIC uint8_t
      5 readtrans(const char *buf)
      6 {
      7 	uint8_t t;
      8 
      9 	for (t = 0; t < 48; t++)
     10 		if (!strncmp(buf, transstr[t], 11))
     11 			return t;
     12 
     13 	LOG("readtrans error\n");
     14 	return UINT8_ERROR;
     15 }
     16 
     17 STATIC void
     18 writetrans(uint8_t t, char *buf)
     19 {
     20 	if (t >= 48)
     21 		memcpy(buf, "error trans", 11);
     22 	else
     23 		memcpy(buf, transstr[t], 11);
     24 	buf[11] = '\0';
     25 }