////////////////////////////////////////////////////////////////////////// // list server void ListServiceTask::handle_curl_completed( const std::string& response, long status ) { ListServiceResult* ret = new ListServiceResult; ret->status = status; std::string display_name = ""; std::string id = ""; if (status == 200) { try { Json::Value json_root; Json::Value json_value; Json::Reader json_reader; if (json_reader.parse(response.c_str(), json_root)) { json_value = json_root["Owner"]; if (!json_value.empty()) { display_name = json_value["DisplayName"].asString(); id = json_value["ID"].asString(); } json_value = json_root["Buckets"]; if (!json_value.empty()) { for (unsigned int i = 0; i < json_value.size(); ++ i) { unsigned long long consumed_bytes = json_value[i]["ConsumedBytes"].asUInt(); std::string creation_date = json_value[i]["CreationDate"].asString(); std::string name = json_value[i]["Name"].asString(); ListServiceItem bucket_item; bucket_item.bytes = consumed_bytes; bucket_item.name = string2CString(Utf8ToMultiByte(name)); bucket_item.date = string2CString(creation_date); ret->items.push_back(bucket_item); } } } } catch (...) { ret->status = 999; } } ret->display_name = string2CString(display_name); ret->id = string2CString(id); AfxGetApp()->GetMainWnd()->PostMessage(WM_MAINDLG_ListServiceResult, (WPARAM)0, (LPARAM)ret); }
void GLglutCreateWindowNamed(void) { Proto tmp; char * p; tmp = (Proto) stackAt(Cpu, 4); p = string2CString(tmp); glutCreateWindow(p); VMReturn(Cpu, (unsigned int) nil, 4); }
void GDstringwithFontXYColor(void) { Proto proto; Proto tmp; Proto blob; Proto strObj; gdImagePtr imgPtr; gdFontPtr fntPtr; char * p; int x1,y1; int font; int index; char * buff; proto = (Proto) stackAt(Cpu, 2); objectGetSlot(proto, stringToAtom("_gdp"), &blob); p = (char *) objectPointerValue(blob); memcpy(&imgPtr, p, sizeof(imgPtr)); tmp = (Proto) stackAt(Cpu, 4); strObj = tmp; tmp = (Proto) stackAt(Cpu, 5); font= objectIntegerValue(tmp); fntPtr = getFontPtr(font); tmp = (Proto) stackAt(Cpu, 6); x1 = objectIntegerValue(tmp); tmp = (Proto) stackAt(Cpu, 7); y1 = objectIntegerValue(tmp); tmp = (Proto) stackAt(Cpu, 8); index = objectIntegerValue(tmp); buff = string2CString(strObj); gdImageString(imgPtr, fntPtr, x1, y1, buff, index); celfree(buff); VMReturn(Cpu, (unsigned int) proto, 8); }
void GetAclTask::handle_curl_completed( const std::string& response, long status ) { GetAclResult* ret = new GetAclResult; ret->status = status; ret->buckname = _buckname; ret->objname = _objname; ret->item = _item; char* pow[] = {"read", "write", "read_acp", "write_acp"}; std::map<std::string, char> pow_mark_map; for (int i = 0; i < ARRAY_SIZE(pow); ++ i) { pow_mark_map.insert(std::map<std::string, char>:: value_type(pow[i], 1 << i)); } if (status == 200) { try { Json::Value json_root; Json::Value json_value; Json::Reader json_reader; if (json_reader.parse(response.c_str(), json_root)) { if (!json_root.empty()) { std::string owner = api_helper::asString(json_root["Owner"]); ret->owner = string2CString(owner); json_value = json_root["ACL"]; if (!json_value.empty()) { Json::Value::Members mem_names = json_value.getMemberNames(); Json::Value::Members::iterator it_name = mem_names.begin(); for (; it_name != mem_names.end(); ++ it_name) { std::string key = *it_name; char pow_mark = 0; Json::Value acl_value = json_value[key.c_str()]; if (!acl_value.empty()) { for (unsigned int j = 0; j < acl_value.size(); ++ j) { std::string str = acl_value[j].asString(); std::map<std::string, char>::iterator it = pow_mark_map.find(str); if (it != pow_mark_map.end()) { pow_mark |= it->second; } } ret->acls.insert(make_pair(key, pow_mark)); } } } } } } catch (...) { ret->status = 999; } } AfxGetApp()->GetMainWnd()->PostMessage(WM_MAINDLG_GetAclResult, (WPARAM)0, (LPARAM)ret); }
void ListBucketTask::handle_curl_completed( const std::string& response, long status ) { ListBucketResult* ret = new ListBucketResult; ret->status = status; if (status == 200) { try { Json::Value json_root; Json::Value json_value; Json::Reader json_reader; if (json_reader.parse(response.c_str(), json_root)) { json_value = json_root["CommonPrefixes"]; if (!json_value.empty()) { for (unsigned int i = 0; i < json_value.size(); ++ i) { std::string name = json_value[i]["Prefix"].asString(); ListBucketItem item; item.is_dir = true; item.name = string2CString(Utf8ToMultiByte(name)); ret->items.push_back(item); } } json_value = json_root["Contents"]; if (!json_value.empty()) { for (unsigned int i = 0; i < json_value.size(); ++ i) { std::string name = json_value[i]["Name"].asString(); std::string sha1 = json_value[i]["SHA1"].asString(); std::string md5 = json_value[i]["MD5"].asString(); std::string date = json_value[i]["Last-Modified"].asString(); std::string owner = json_value[i]["Owner"].asString(); unsigned long long size = json_value[i]["Size"].asUInt(); ListBucketItem item; item.is_dir = false; item.name = string2CString(Utf8ToMultiByte(name)); item.sha1 = string2CString(sha1); item.md5 = string2CString(md5); item.date = string2CString(date); item.owner = string2CString(owner); item.size = size; ret->items.push_back(item); } } } } catch (...) { ret->status = 999; } } ret->buckname = _buckname; ret->foldername = _prefix; AfxGetApp()->GetMainWnd()->PostMessage(WM_MAINDLG_ListBucketResult, (WPARAM)0, (LPARAM)ret); }