int executeCommande(char* commande) { char** arguments; int nombreArguments=0; pid_t pid; int retourExec=0; arguments = charToArgs(commande,&nombreArguments); if(!cmpstr(arguments[0],"exit")) { freeMatrice(arguments,nombreArguments); return -2; } if(!cmpstr(arguments[0],"cd")) { if(arguments[1]==NULL || !cmpstr(arguments[1],"~")) { char* home = getEnv("HOME"); if(home!=NULL) { printf("goto : %s\n",home); chdir(home); }else { write(1,"no HOME in env\n",15); freeMatrice(arguments,nombreArguments); return -1; } }else{ chdir(arguments[1]); } } pid = fork(); if(pid==0) { if(cmpstr(arguments[0],"cd")) { retourExec = execvp(arguments[0],arguments); if(retourExec==-1) { write(0,arguments[0],lenstr(arguments[0])); write(0," : Command not found\n",21); kill (getpid(),SIGINT); pid=-1; } } } freeMatrice(arguments,nombreArguments); return pid; }
/** Compare two connection URIs */ static unsigned char pg_uri_cmp(db_uri_t* uri1, db_uri_t* uri2) { struct pg_uri* puri1, *puri2; if (!uri1 || !uri2) return 0; puri1 = DB_GET_PAYLOAD(uri1); puri2 = DB_GET_PAYLOAD(uri2); if (puri1->port != puri2->port) return 0; if (cmpstr(puri1->username, puri2->username, strcmp)) return 0; if (cmpstr(puri1->password, puri2->password, strcmp)) return 0; if (cmpstr(puri1->host, puri2->host, strcasecmp)) return 0; if (cmpstr(puri1->database, puri2->database, strcmp)) return 0; return 1; }
int main(int argc, char **argv) { int cmp; char *rel; if(argc!=3) { fprintf(stderr, "usage: %s string1 string2\n", argv[0]); exit(1); } cmp = cmpstr(argv[1], argv[2]); switch(cmp) { case 0: rel = "=="; break; case 1: rel = ">"; break; case 2: rel = "<"; break; default: assert(0); } printf("\"%s\" %s \"%s\"\n", argv[1], rel, argv[2]); return cmp; }
/* * Compare two connection identifiers */ static unsigned char my_uri_cmp(db_uri_t* uri1, db_uri_t* uri2) { struct my_uri* muri1, *muri2; if (!uri1 || !uri2) return 0; muri1 = DB_GET_PAYLOAD(uri1); muri2 = DB_GET_PAYLOAD(uri2); if (muri1->port != muri2->port) return 0; if (cmpstr(muri1->username, muri2->username, strcmp)) return 0; if (cmpstr(muri1->password, muri2->password, strcmp)) return 0; if (cmpstr(muri1->host, muri2->host, strcasecmp)) return 0; if (cmpstr(muri1->database, muri2->database, strcmp)) return 0; return 1; }
void GMTS::key_resolution() { Group_Manager g {group_id}; std::string m {cmpstr(g.get_key(),group_key)}; TEST_ASSERT_MSG(g.get_key()==group_key,m.c_str()); Group_Manager h {group_key}; Group_Manager j {group_name, 1}; TEST_ASSERT(g.get_id()==group_id); TEST_ASSERT(j.get_id()==group_id); }
/** Compares two LDAP connection URIs. * This function is called whenever the database abstraction layer in * SER needs to compare to URIs with the ldap scheme. The function * compares hosts and port numbers of both URIs (host part comparison * is case insensitive). The URI comparison is mainly used to * by the connection pool to determine if a connection to a given * server already exists. **/ static unsigned char ld_uri_cmp(db_uri_t* uri1, db_uri_t* uri2) { struct ld_uri* luri1, *luri2; if (!uri1 || !uri2) return 0; luri1 = DB_GET_PAYLOAD(uri1); luri2 = DB_GET_PAYLOAD(uri2); if (luri1->ldap_url->lud_port != luri2->ldap_url->lud_port) return 0; if (cmpstr(luri1->ldap_url->lud_host, luri2->ldap_url->lud_host, strcasecmp)) return 0; return 1; }
int main () { char str1[10], str2[10]; int x; printf ("\n Enter a string [length<10] : "); scanf ("%s", str1); printf ("\n Enter another string [length<10] : "); scanf ("%s", str2); x = cmpstr (str1, str2); if (x == 0) printf ("\n Both the Strings are equal! \n"); else printf ("\n The Strings are not equal! \n"); return 0; }
void programs_run(unsigned char input[]) { unsigned char input_program[INPUT_BUFFER_SIZE] = { 0 }; unsigned char input_args[INPUT_BUFFER_SIZE] = { 0 }; int i = 0; while(input[i] != ' ' && input[i] != '\0') { input_program[i] = input[i]; i++; } int j = 0; i++; while(input[i] != '\0') { input_args[j] = input[i]; i++; j++; } if(cmpstr(input_program, "echo")) { start_echo_program(input_args); } }
int cmp_ignore_case(char *stra, char *strb) { char a[STR_SIZE], b[STR_SIZE]; strcpyupper(a, stra); strcpyupper(b, strb); return cmpstr(a, b); }
void caseif(int x) { extern int falsef; register int notflag, true; tchar i, j; enum warn w = warn; int flt = 0; if (x == 3) goto i2; if (x == 2) { notflag = 0; true = iflist ? iflist[ifx] : 0; goto i1; } true = 0; skip(1); if ((cbits(i = getch())) == '!') { notflag = 1; if (xflag == 0) /*EMPTY*/; else if ((cbits(i = getch())) == 'f') flt = 1; else ch = i; } else if (xflag && cbits(i) == 'f') { flt = 1; notflag = 0; } else { notflag = 0; ch = i; } if (flt) i = atof0() > 0; else i = (int)atoi0(); if (!nonumb) { if (i > 0) true++; goto i1; } i = getch(); switch (cbits(i)) { case 'e': if (!(numtab[PN].val & 01)) true++; break; case 'o': if (numtab[PN].val & 01) true++; break; #ifdef NROFF case 'n': true++; case 't': #endif #ifndef NROFF case 't': true++; case 'n': #endif break; case 'c': if (xflag == 0) goto dfl; warn &= ~WARN_CHAR; tryglf++; if (!skip(1)) { j = getch(); true = !ismot(j) && cbits(j) && cbits(j) != ' '; } tryglf--; warn = w; break; case 'r': case 'd': if (xflag == 0) goto dfl; warn &= ~(WARN_MAC|WARN_SPACE|WARN_REG); if (!skip(1)) { j = getrq(2); true = (cbits(i) == 'r' ? usedr(j) != NULL : findmn(j) != NULL); } warn = w; break; case ' ': break; default: dfl: true = cmpstr(i); } i1: true ^= notflag; if (x == 1) { if (ifx >= NIF) growiflist(); iflist[ifx] = !true; } if (true) { if (frame->loopf & LOOP_EVAL) { if (nonumb) goto i3; frame->loopf &= ~LOOP_EVAL; frame->loopf |= LOOP_NEXT; } i2: while ((cbits(i = getch())) == ' ') ; if (cbits(i) == LEFT) goto i2; ch = i; nflush++; } else { i3: if (frame->loopf & LOOP_EVAL) frame->loopf = LOOP_FREE; copyf++; falsef++; eatblk(0); copyf--; falsef--; } }
pilo::i32_t functional_memory_pool_basic(void* param) { M_UNUSED(param); typedef testing_pod_info* testing_pod_info_ptr; testing_pod_info_ptr* saved_info = new testing_pod_info_ptr[TEST_UNIT_IN_POOL_NUM]; pilo::core::memory::memory_pool<sizeof(test::testing_pod_info), 1024> pool; for (int i = 0; i < TEST_UNIT_IN_POOL_NUM; i++) { test::testing_pod_info* info = (test::testing_pod_info*) pool.allocate(); info->m_id = i; info->m_name = pilo::core::string::fixed_astring<128>(i); saved_info[i] = info; } if (pool.piece_count() != 1024) { return -1; } for (int i = 0; i < TEST_UNIT_IN_POOL_NUM; i++) { if (saved_info[i]->m_id != i) { return -10; } pilo::core::string::fixed_astring<128> cmpstr(i); if (saved_info[i]->m_name != cmpstr) { return -20; } } for (int i = 0; i < TEST_UNIT_IN_POOL_NUM; i++) { pool.deallocate(saved_info[i]); } if (pool.piece_count() != 1024) { return -2; } pool.clear(); if (pool.piece_count() != 1024) { return -3; } pool.reset(); if (pool.piece_count() != 0) { return -4; } delete [] saved_info; return 0; }