static char *dataDescription(WMPropList * plist) { const unsigned char *data; char *retVal; int i, j, length; data = WMDataBytes(plist->d.data); length = WMGetDataLength(plist->d.data); retVal = (char *)wmalloc(2 * length + length / 4 + 3); retVal[0] = '<'; for (i = 0, j = 1; i < length; i++) { retVal[j++] = num2char((data[i] >> 4) & 0x0f); retVal[j++] = num2char(data[i] & 0x0f); if ((i & 0x03) == 3 && i != length - 1) { /* if we've just finished a 32-bit int, add a space */ retVal[j++] = ' '; } } retVal[j++] = '>'; retVal[j] = '\0'; return retVal; }
static void pasteText(WMView * view, Atom selection, Atom target, Time timestamp, void *cdata, WMData * data) { TextField *tPtr = (TextField *) view->self; char *str; /* Parameter not used, but tell the compiler that it is ok */ (void) selection; (void) target; (void) timestamp; (void) cdata; tPtr->flags.waitingSelection = 0; if (data != NULL) { str = (char *)WMDataBytes(data); WMInsertTextFieldText(tPtr, str, tPtr->cursorPosition); NOTIFY(tPtr, didChange, WMTextDidChangeNotification, (void *)WMInsertTextEvent); } else { int n; str = XFetchBuffer(tPtr->view->screen->display, &n, 0); if (str != NULL) { str[n] = 0; WMInsertTextFieldText(tPtr, str, tPtr->cursorPosition); XFree(str); NOTIFY(tPtr, didChange, WMTextDidChangeNotification, (void *)WMInsertTextEvent); } } }
static unsigned hashPropList(const void *param) { WMPropList *plist= (WMPropList *) param; unsigned ret = 0; unsigned ctr = 0; const char *key; int i, len; switch (plist->type) { case WPLString: key = plist->d.string; len = WMIN(strlen(key), MaxHashLength); for (i = 0; i < len; i++) { ret ^= tolower(key[i]) << ctr; ctr = (ctr + 1) % sizeof(char *); } /*while (*key) { ret ^= tolower(*key++) << ctr; ctr = (ctr + 1) % sizeof (char *); } */ break; case WPLData: key = WMDataBytes(plist->d.data); len = WMIN(WMGetDataLength(plist->d.data), MaxHashLength); for (i = 0; i < len; i++) { ret ^= key[i] << ctr; ctr = (ctr + 1) % sizeof(char *); } break; default: wwarning(_("Only string or data is supported for a proplist dictionary key")); wassertrv(False, 0); break; } return ret; }