src/win32.cpp
branchnoai
changeset 9694 e72987579514
parent 9631 8a2d1c2ceb88
child 9701 d1ac22c62f64
equal deleted inserted replaced
9693:31fcaa5375a1 9694:e72987579514
   108 	SYSTEMTIME file_time;
   108 	SYSTEMTIME file_time;
   109 };
   109 };
   110 
   110 
   111 static uint32 *_crc_table;
   111 static uint32 *_crc_table;
   112 
   112 
   113 static void MakeCRCTable(uint32 *table) {
   113 static void MakeCRCTable(uint32 *table)
       
   114 {
   114 	uint32 crc, poly = 0xEDB88320L;
   115 	uint32 crc, poly = 0xEDB88320L;
   115 	int i;
   116 	int i;
   116 	int j;
   117 	int j;
   117 
   118 
   118 	_crc_table = table;
   119 	_crc_table = table;
   124 		}
   125 		}
   125 		table[i] = crc;
   126 		table[i] = crc;
   126 	}
   127 	}
   127 }
   128 }
   128 
   129 
   129 static uint32 CalcCRC(byte *data, uint size, uint32 crc) {
   130 static uint32 CalcCRC(byte *data, uint size, uint32 crc)
       
   131 {
   130 	for (; size > 0; size--) {
   132 	for (; size > 0; size--) {
   131 		crc = ((crc >> 8) & 0x00FFFFFF) ^ _crc_table[(crc ^ *data++) & 0xFF];
   133 		crc = ((crc >> 8) & 0x00FFFFFF) ^ _crc_table[(crc ^ *data++) & 0xFF];
   132 	}
   134 	}
   133 	return crc;
   135 	return crc;
   134 }
   136 }
  1012 /**
  1014 /**
  1013  * Insert a chunk of text from the clipboard onto the textbuffer. Get TEXT clipboard
  1015  * Insert a chunk of text from the clipboard onto the textbuffer. Get TEXT clipboard
  1014  * and append this up to the maximum length (either absolute or screenlength). If maxlength
  1016  * and append this up to the maximum length (either absolute or screenlength). If maxlength
  1015  * is zero, we don't care about the screenlength but only about the physical length of the string
  1017  * is zero, we don't care about the screenlength but only about the physical length of the string
  1016  * @param tb Textbuf type to be changed
  1018  * @param tb Textbuf type to be changed
  1017  * @return true on successfull change of Textbuf, or false otherwise
  1019  * @return true on successful change of Textbuf, or false otherwise
  1018  */
  1020  */
  1019 bool InsertTextBufferClipboard(Textbuf *tb)
  1021 bool InsertTextBufferClipboard(Textbuf *tb)
  1020 {
  1022 {
  1021 	HGLOBAL cbuf;
  1023 	HGLOBAL cbuf;
  1022 	char utf8_buf[512];
  1024 	char utf8_buf[512];
  1260 		}
  1262 		}
  1261 	}
  1263 	}
  1262 
  1264 
  1263 	return E_INVALIDARG;
  1265 	return E_INVALIDARG;
  1264 }
  1266 }
       
  1267 
       
  1268 /** Determine the current user's locale. */
       
  1269 const char *GetCurrentLocale(const char *)
       
  1270 {
       
  1271 	char lang[9], country[9];
       
  1272 	if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, lang, lengthof(lang)) == 0 ||
       
  1273 	    GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, country, lengthof(country)) == 0) {
       
  1274 		/* Unable to retrieve the locale. */
       
  1275 		return NULL;
       
  1276 	}
       
  1277 	/* Format it as 'en_us'. */
       
  1278 	static char retbuf[6] = {lang[0], lang[1], '_', country[0], country[1], 0};
       
  1279 	return retbuf;
       
  1280 }