void ResolumeOSC::setClipAutoPilot(int layerID, int clipID, int value) { string address = "/layerX/clipX/autopilot/action"; address[6] = intToChar(layerID); address[12] = intToChar(clipID); send(address, value); }
void ResolumeOSC::playClip(int layerID, int clipID) { string address = "/layerX/clipX/connect"; address[6] = intToChar(layerID); address[12] = intToChar(clipID); send(address, 1); }
void ResolumeOSC::setClipPlayMode(int layerID, int clipID, int value) { string address = "/layerX/clipX/video/position/playmode"; address[6] = intToChar(layerID); address[12] = intToChar(clipID); send(address, value); }
/* Print the fib sequence */ void fib(int fd,int n){ int first = 0, second = 1, next, c; char *fib_num = malloc(sizeof(int)*n); Send(fd, "\nPrinting the Fibonacci sequence:\n"); for ( c = 0 ; c < n ; c++ ) { if ( c <= 1 ) next = c; else { next = first + second; first = second; second = next; } // convert int to str sprintf(fib_num, "%d\n", next); Send(fd,fib_num); } Send(fd, "\n The "); Send(fd, intToChar(n)); Send(fd, "th digit of Fibonacci is "); Send(fd, intToChar(next)); }
void print() { #ifdef LEGACY_IDE clrscr(); #else system("CLS"); #endif char c; cout<<" "; for (int i = 'A'; i <= 'H'; i++) { c = i; cout<<c<<" "; } cout<<endl<<endl<<endl<<endl<<endl; for (int i = 0; i <= 7; i++) { cout<<endl<<endl<<endl<<endl<<endl<<(i + 1)<<" "; for (int j = 0; j <= 7; j++) { c = intToChar(Game[j][i]); cout<<c<<" "; } } }
void ChatRoom::inviteUser(User* user, int invID) { CRITICAL_SECTION critical; InitializeCriticalSection(&critical); if(user != NULL) { newUsers = 1; EnterCriticalSection(&critical); char* temp = intToChar(user->getUserId()); LeaveCriticalSection(&critical); int n = strlen(temp); char* buffer = new char[n + 1]; strcpy(buffer, temp); buffer[n] = ' '; buffer[n + 1] = '\0'; Message m(4, invID, id, 1, buffer); for(map<int, User*>::iterator it = users.begin(); it != users.end(); ++it) { EnterCriticalSection(&critical); if((*it).first != user->getUserId()) { m.sendTo((*it).second->getSocket()); } LeaveCriticalSection(&critical); } EnterCriticalSection(&critical); addUser(user); user->assigneToRoom(this); LeaveCriticalSection(&critical); } }
char Encode::encryptChar(char c){ int enc; enc = charToInt(c); // Plugboard first time enc = plugboard->encode(enc); // Rotors encoding for(int i = 0; i < numOfRotorFiles; ++i){ enc = rotors[i]->encode(enc); } // Reflector enc = reflector->encode(enc); // Rotors encoding backwords for(int i = numOfRotorFiles - 1; i >= 0; --i){ enc = rotors[i]->encodeBackwords(enc); } // Plugboard second time enc = plugboard->encode(enc); // Rotate rotors if(numOfRotorFiles > 0){ rotateRotors(); } return intToChar(enc); }
chatRoom::chatRoom(int rId, QTcpSocket *socket, QTabWidget *tab, MainUser* mainUser, QMap<int, User*>* global) : ui(new Ui::ChatRoom) { ui->setupUi(this); this->tab = tab; this->roomID = rId; this->tabID = tab->count(); //asd //ChatRoomInterFace *inf = new ChatRoomInterFace; this->mainUser = mainUser; QString roomName = intToChar(rId); tab->addTab(this, "Private(" + roomName + ")"); this->display = ui->plainTextEdit; this->input = ui->textEdit; this->sendButton = ui->pushButton; this->sendFile = ui->pushButton_4; this->leaveRoom = ui->pushButton_3; this->add = ui->pushButton_2; this->userlist = ui->listWidget; this->socket = socket; this->uname = ui->lineEdit; this->sendButton->installEventFilter(this); this->input->installEventFilter(this); connect(sendButton, SIGNAL(clicked()), this, SLOT(sendText())); connect(leaveRoom, SIGNAL(clicked()), this, SLOT(leave())); connect(add, SIGNAL(clicked()), this, SLOT(inviteUser())); connect(sendFile, SIGNAL(clicked()), this, SLOT(sendFileSlot())); this->global = global; userNr = 0; //if() }
//把int转换为char× char* tochar(int i) { if(i==0) { char *temp = new char[2]; temp[0] = '0'; temp[1] = '\0'; return temp; } //求i 的位数 int j = 1; int l = 0; while(i>=j) { j *= 10; l++; } j /= 10; char* location = new char[l+1]; for(int k=0;k<l;k++) { location[k] = intToChar(i/j); i %= j; j /=10; } location[l] = '\0'; return location; }
//Update Dictionary void updatedictionary(struttura *str) { int retval; char query[200]; //Check if the word is present on the global dictionary sprintf (query, " select parola from globale where parola like \'%s\';",intToChar(str->ins.new_word)); //printf("\n%s\n",query); if(sqlite3_prepare_v2(str->tp.db,query,-1,&str->tp.stmt,0)) { fprintf(stderr,"error : programm %s ,function updatedictionary(..) sqlite3_prepare_v2 return error\n ",NameProgramm); return; } retval = sqlite3_step(str->tp.stmt); if(retval != SQLITE_ROW) { sprintf (query, "insert into globale (codice,parola,frequenza) values (\'%s\',\'%s\',3);",str->ins.key_numbers,intToChar(str->ins.new_word)); if (sqlite3_exec(str->tp.db,query,0,0,0)) fprintf(stderr,"error : programm %s ,function updatedictionary(..) sqlite3_exec return error\n ",NameProgramm); } gdk_window_process_all_updates (); }
void window_insert(struttura *str) { GtkWidget *winDialog,*button1,*button2,*label; GtkDialog *dialog; char slabel[LEN_WORD_DB+16]; gtk_widget_hide(str->window); winDialog = gtk_dialog_new(); dialog=GTK_DIALOG(winDialog); gtk_window_set_title(GTK_WINDOW(winDialog), "new word?"); button1=gtk_dialog_add_button(dialog,"cancel",0); button2=gtk_dialog_add_button(dialog,"insert",1); snprintf(slabel,LEN_WORD_DB+16,"insert '%s' in db?",intToChar(str->ins.new_word)); label = gtk_label_new (slabel); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(dialog)),label, TRUE, TRUE, 0); gtk_widget_show (label); g_signal_connect(G_OBJECT(button1), "clicked",G_CALLBACK (gtk_widget_destroy), winDialog); g_signal_connect(G_OBJECT(button2), "clicked",G_CALLBACK(button_pressed_insert), str); g_signal_connect_swapped (winDialog, "destroy", G_CALLBACK (gtk_widget_destroy), winDialog); gtk_dialog_run(dialog); setMove(str,str->window); gtk_widget_show(str->window); gtk_widget_destroy(winDialog); ins(str); }
int GraphicPipeline::enableLight(Light * currentLight, int index) { int isSet = false; string lightCount = "GL_LIGHT"; lightCount += intToChar(index); glEnable(GL_LIGHTING); float * lightPosition = new float[4] ; lightPosition[0] = currentLight->getTranslation()->x; lightPosition[1] = currentLight->getTranslation()->y; lightPosition[2] = currentLight->getTranslation()->z; lightPosition[3] = currentLight->getPos_direct(); // farbiges licht hinzufuegen glLightfv(GL_LIGHT0, GL_POSITION, lightPosition ); if(currentLight->getDiffuse() != NULL) //glLightfv(index, GL_DIFFUSE, currentLight->getDiffuse()); glLightfv(GL_LIGHT0, GL_DIFFUSE, currentLight->getDiffuse()); if(currentLight->getAmbient() != NULL) //glLightfv(index, GL_AMBIENT, currentLight->getAmbient()); glLightfv(GL_LIGHT0, GL_AMBIENT, currentLight->getAmbient()); if(currentLight->getSpecular() != NULL) //glLightfv(index, GL_SPECULAR, currentLight->getSpecular()); glLightfv(GL_LIGHT0, GL_SPECULAR, currentLight->getSpecular()); //for (int i = 0; i < index; i++) { //glEnable(index); glEnable(GL_LIGHT0); //} return isSet; }
int prepareIntial() { if (xi > 96) { xi -= 32; } if (xi < 'A' || xi > 'H' || yi < '1' || yi > '8') { cout<<endl<<"Invalid coordinates!"; return 0; } xi -= 65; yi -= 49; ci = intToChar(Game[xi][yi]); if (ci == ' ') { cout<<endl<<"Invalid piece!"; return 0; } else if (ci > 96) { cout<<endl<<"You must select your own piece"; return 0; } cout<<ci; return 1; }
int main() { int number=123; char str[10]; intToChar(number,str); myPrint(str,strlen(str)); return 0; }
/** * @brief createTable creates the database and metadata. * @param registerSize is the size for each registry. * @param columnSizes is the sizes for each column. */ bool writefile::createTable(int* registerSize, array<int>* columnSizes , array<char*>* columnNames , string* pFile){ int offset = 0; string add; string theFileName = createNewFile(*pFile); writefile::writeColumnNames(&theFileName, columnNames); ofstream database (theFileName.c_str() , ios::trunc); //check if buffer = true if(database.is_open()){ //cout << "****Database succesfully created***" << endl; }else{ //cout << "****Database could not be created***" << endl; return false; } //Register size valideichion. if(*registerSize >= K->MAX_REGISTER_SIZE){ cout << "Error: Register size beyond max size" << endl; return false; }else{ database << K->TRIPLE_NULL; add = toChar(*registerSize); checkSize(&add, K->DEFAULT_REGISTER_SIZE); database.write(add.c_str() , K->DEFAULT_REGISTER_SIZE); } //set column sizes on file array<int> tempArr = *columnSizes; for (int i = 0 ; i < tempArr.getLenght() ; i++) { int integerElem = tempArr[i]; add = toChar(integerElem); checkSize(&add,K->DEFAULT_COLUMN_SIZE); database.write(add.c_str() , K->DEFAULT_COLUMN_SIZE); } //sets seek on the end, gets the address then turns it to char //to insert on the beginning. database.seekp(offset, ios::end); int meta = database.tellp(); string metadata = intToChar(meta); checkSize(&metadata, K->METADATA_SIZE); database.seekp(K->ZE_ROW); if (metadata.length() <= 3){ const char *p = metadata.c_str(); while (*p != '\0') database.put( *(p++) ); }else{ //cout << "Invalid metadata size. Yoh ! Pls kontact ur admin...\n"; return false; } database.seekp(K->ZE_ROW , ios::end); database.close(); return true; }
std::string intToStr(int n, std::string s) { if ((n / 10) != 0) { s = intToStr((n / 10), s); } int intDigit = n % 10; char charDigit = intToChar(intDigit); s.append(1, charDigit); return s; }
/* calc of Sin func ***Will only calculate sin of ints */ void sin_func(int fd, int n) { // do calculation double ans = sin((double) n); char *msg = malloc(sizeof(char)*128); char *n_char = intToChar(n); strcpy(msg,"Sin("); strcat(msg,n_char); strcat(msg,") = "); Send(fd, msg); Send(fd, doubleToChar(ans)); }
string toHex(int num) { string hex = ""; int n = num; unsigned bin; for (int i = 0; i < 8; i++) { bin = 15 << ((7 - i) * 4); bin = (bin & n) >> ((7 - i) * 4); char h = intToChar(bin); if (bin != 0 || hex.size() != 0) hex.push_back(h); } if (hex.size() == 0) hex = "0"; return hex; }
void dataPush() { float cpuLoad=(1000-idle)*0.1; intToChar(cpuLoad,cpuLoadBuffer[myQueue.end]); if(isQueueFull(&myQueue)!=1) { enqQueue(&myQueue,(void *)cpuLoadBuffer[myQueue.end]); } else { deqQueue(&myQueue); enqQueue(&myQueue,(void *)cpuLoadBuffer[myQueue.end]); } }
int prepareFinal() { if (xf > 96) { xf -= 32; } if (xf < 'A' || xf > 'H' || yf < '1' || yf > '8') { cout<<endl<<"Invalid coordinates!"; return 0; } xf -= 65; yf -= 49; cf = intToChar(Game[xf][yf]); cout<<cf; return 1; }
int isObjectDetected(void){ int reDist; volatile int i; #ifdef DISTANCE_DEBUG char buf[7]; #endif //get distance : AEB distance[0]=sonarGetDistance(); #ifdef USE_PIR_SENSOR for(i=1;i<3;i++){ distance[i] = getDistance(i-1); } #endif #ifdef DISTANCE_DEBUG for(i=0;i<3;i++){ intToChar(distance[i],7,buf); TransmitData(buf); TransmitData("-"); } TransmitData("\r\n"); #endif if(distance[0]<160){ reDist = distance[0]; }else{ reDist=OBJECT_NOT_DETECTED; #ifdef USE_PIR_SENSOR if((distance[1]<65)){ reDist = distance[1]; }else{ if(distance[2]<65){ reDist = distance[2]; }else{ reDist=OBJECT_NOT_DETECTED; } } #endif } return reDist; }
char* intToString(int number, int base){ int count = 0; if(base == 10){ char* str = calloc(8, sizeof(char)); sprintf(str, "%d", number); return str; } else if (base == 2){ char *temp = calloc(25, sizeof(char)); bzero(temp, 25); while(number>0){ int rem = number%2; char xe = intToChar(rem); strncat(temp, &xe, 1); count++; number/=2; } char* ret = reverse(temp); // free(temp); return ret; } else { printf("Could not convert to base %d\n", base); } return NULL; }
void chatRoom::inviteUser() { QString username = ui->lineEdit->text(); bool found = false; int userId = 0; for(QMap<int, User*>::Iterator it = global->begin(); it != global->end(); ++it) { User* user = it.value(); if(user->getUsername().compare(username) == 0) { //addUser(user->getId(), user); found = true; userId = user->getId(); } } if(!found) { QMessageBox::StandardButton resBtn = QMessageBox::question( this, "ChatClient", tr("User not found\n"), QMessageBox::Ok | QMessageBox::Cancel); if (resBtn == QMessageBox::Ok || resBtn == QMessageBox::Cancel) { ui->lineEdit->setText(""); } } else { QMap<int, User*>::Iterator it = users.find(userId); if(it != users.end()) { QMessageBox::StandardButton resBtn = QMessageBox::question( this, "ChatClient", tr("User already joined!\n"), QMessageBox::Ok | QMessageBox::Cancel); if (resBtn == QMessageBox::Ok || resBtn == QMessageBox::Cancel) { ui->lineEdit->setText(""); } } else { Message m(6, mainUser->getUserId(), roomID, 1, intToChar(userId)); m.send(socket); } } }
void ResolumeOSC::setLayerOpacity(int layerID, float value) { string address = "/layerX/video/opacity/values"; address[6] = intToChar(layerID); send(address, value); }
void populate(){ int i; for(i=0; i<26; i++){ ordPrioChar[i] = intToChar(i); } }
void EDSRSA(char *M_fname, char *n_fname, char *e_fname, char *d_fname) { std::ifstream in(M_fname); int *M_hash = (int*)md5(&in), i; BigInt M(intToChar(M_hash[3])), N(n_fname, false), E(e_fname, false), D(d_fname, false); M *= BigInt("10000000000"); M += BigInt(intToChar(M_hash[2])); M *= BigInt("10000000000"); M += BigInt(intToChar(M_hash[1])); M *= BigInt("10000000000"); M += BigInt(intToChar(M_hash[0])); BigInt Signature("1"), Encode("1"); BigInt DegreeNet[RNet]; DegreeNet[0] = M; DegreeNet[0] %= N; for(i = 1; i < RNet; i++) { DegreeNet[i] = DegreeNet[i-1] * DegreeNet[i-1]; DegreeNet[i] %= N; } BigInt degreeNum[RNet]; degreeNum[0] = BigInt("1"); for(int i = 1; i < RNet; i++) degreeNum[i] = degreeNum[i-1] * BigInt("2"); BigInt I("0"); for(int j = RNet-1; j >= 0;) { if(D >= I + degreeNum[j]) { Signature *= DegreeNet[j]; Signature %= N; I += degreeNum[j]; } else j--; } ///////////////////////////// DegreeNet[0] = Signature; DegreeNet[0] %= N; for(i = 1; i < RNet; i++) { DegreeNet[i] = DegreeNet[i-1] * DegreeNet[i-1]; DegreeNet[i] %= N; } I = BigInt("0"); for(int j = RNet-1; j >= 0;) { if(E >= I + degreeNum[j]) { Encode *= DegreeNet[j]; Encode %= N; I += degreeNum[j]; } else j--; } ///////////////////////////// M.TextWrite("hash.txt"); Signature.TextWrite("signature.txt"); Encode.TextWrite("encode.txt"); if( M % N == Encode) std::cout<<"OK\n"; else std::cout<<"NOT OK\n"; }
void ResolumeOSC::setLayerMixerOption1(int layerID, int value) { string address = "/layerX/video/mixeroption1"; address[6] = intToChar(layerID); send(address, value); }
void EncodingEDSRSA(char *M_fname, char *nA_fname, char *eA_fname, char *dA_fname, char *nB_fname, char *eB_fname, char *dB_fname) { std::ifstream in(M_fname); int *M_hash = (int*)md5(&in), i; BigInt M(intToChar(M_hash[3])), NA(nA_fname, false), EA(eA_fname, false), DA(dA_fname, false); M *= BigInt("10000000000"); M += BigInt(intToChar(M_hash[2])); M *= BigInt("10000000000"); M += BigInt(intToChar(M_hash[1])); M *= BigInt("10000000000"); M += BigInt(intToChar(M_hash[0])); BigInt NB(nB_fname, false), EB(eB_fname, false), DB(dB_fname, false); BigInt Signature("1"), Code("1"), Encode("1"), CheckSign("1"); BigInt DegreeNet[RNet]; DegreeNet[0] = M; DegreeNet[0] %= NA; for(i = 1; i < RNet; i++) { DegreeNet[i] = DegreeNet[i-1] * DegreeNet[i-1]; DegreeNet[i] %= NA; } BigInt degreeNum[RNet]; degreeNum[0] = BigInt("1"); for(int i = 1; i < RNet; i++) degreeNum[i] = degreeNum[i-1] * BigInt("2"); BigInt I("0"); for(int j = RNet-1; j >= 0;) { if(DA >= I + degreeNum[j]) { Signature *= DegreeNet[j]; Signature %= NA; I += degreeNum[j]; } else j--; } ////////////////////////////// DegreeNet[0] = Signature; DegreeNet[0] %= NB; for(i = 1; i < RNet; i++) { DegreeNet[i] = DegreeNet[i-1] * DegreeNet[i-1]; DegreeNet[i] %= NB; } I = BigInt("0"); for(int j = RNet-1; j >= 0;) { if(EB >= I + degreeNum[j]) { Code *= DegreeNet[j]; Code %= NB; I += degreeNum[j]; } else j--; } ////////////////////////////// DegreeNet[0] = Code; DegreeNet[0] %= NB; for(i = 1; i < RNet; i++) { DegreeNet[i] = DegreeNet[i-1] * DegreeNet[i-1]; DegreeNet[i] %= NB; } I = BigInt("0"); for(int j = RNet-1; j >= 0;) { if(DB >= I + degreeNum[j]) { Encode *= DegreeNet[j]; Encode %= NB; I += degreeNum[j]; } else j--; } ////////////////////////////// DegreeNet[0] = Encode; DegreeNet[0] %= NA; for(i = 1; i < RNet; i++) { DegreeNet[i] = DegreeNet[i-1] * DegreeNet[i-1]; DegreeNet[i] %= NA; } I = BigInt("0"); for(int j = RNet - 1; j >= 0;) { if(EA >= I + degreeNum[j]) { CheckSign *= DegreeNet[j]; CheckSign %= NA; I += degreeNum[j]; } else j--; } ////////////////////////////// M.TextWrite("hash.txt"); Code.TextWrite("code.txt"); Encode.TextWrite("encode.txt"); CheckSign.TextWrite("checksign.txt"); if( M % NA == CheckSign) std::cout<<"OK\n"; else std::cout<<"NOT OK\n"; }
void GeneratedKey(char *p_fname, char *q_fname, char *e_fname, char *name) { BigInt P(p_fname, false), Q(q_fname, false), E(e_fname, false); BigInt N = P * Q, Fi, FiEl("1"), D("1"); Fi = (P - BigInt("1")) * (Q - BigInt("1")); int amount = 5761456; /*std::ifstream num("simpleNum.txt"); amount = Space(num); num.close();*/ std::ifstream ifst("simpleNum.txt"); if(!ifst) { GenetateSimpleList(); ifst.open("simpleNum.txt"); } int **degree, i; char *buf_ch = new char[10]; BigInt A = BigInt(&Fi), B, buf_bi; degree = new int *[2]; for(i = 0; i < 2; i ++) degree[i] = new int [amount]; memset(degree[0], 0, 4 * amount); memset(degree[1], 0, 4 * amount); i = 0; bool end = true; while(end) { buf_ch = getSimpleNum(ifst); if((A % BigInt(buf_ch)) == BigInt("0")) { A /= BigInt(buf_ch); degree[0][i] = charToInt(buf_ch); degree[1][i]++; i = 0; ifst.seekg (0, ifst.beg); } else i++; if(A == BigInt("1")) end = false; } ifst.close(); for(i = 0; i < amount; i++) { if(degree[0][i] != 0) { A = B = BigInt(intToChar(degree[0][i])); A ^= BigInt(intToChar(degree[1][i])); B ^= BigInt(intToChar(degree[1][i] - 1)); buf_bi = A - B; FiEl *= buf_bi; } } FiEl--; BigInt DegreeNet[RNet]; DegreeNet[0] = D * E; DegreeNet[0] %= Fi; for(i = 1; i < RNet; i++) { DegreeNet[i] = DegreeNet[i-1] * DegreeNet[i-1]; DegreeNet[i] %= Fi; } BigInt degreeNum[RNet]; degreeNum[0] = BigInt("1"); for(int i = 1; i < RNet; i++) degreeNum[i] = degreeNum[i-1] * BigInt("2"); BigInt I("0"); for(int j = RNet-1; j >= 0;) { if(FiEl >= I + degreeNum[j]) { D *= DegreeNet[j]; D %= Fi; I += degreeNum[j]; } else j--; } char fname[32]; strcpy(fname, name); strcat(fname, "N.txt"); N.TextWrite(fname); strcpy(fname, name); strcat(fname, "D.txt"); D.TextWrite(fname); };
void ResolumeOSC::clearLayer(int layerID) { string address = "/layerX/clear"; address[6] = intToChar(layerID); send(address, 1); }