int main (int argc, char *argv[]) { MINT *a, *b, *c, *d; short h; mp_set_memory_functions (NULL, NULL, NULL); a = itom (123); b = xtom ("DEADBEEF"); c = itom (0); d = itom (0); move (a, b); madd (a, b, c); msub (a, b, c); mult (a, b, c); mdiv (b, a, c, d); sdiv (b, 2, c, &h); msqrt (a, c, d); pow (b, a, a, c); rpow (a, 3, c); gcd (a, b, c); mcmp (a, b); if (argc > 1) { min (c); mout (a); } mtox (b); mfree(a); exit (0); }
// Escribe la matriz en bruto (BYTE) void writeoutput() { // printf("Escribiendo archivo de salida %s\n", par.f); FILE * fd = fopen(par.f, "wb"); int * it; int i; for(i = 0; i < dimx * dimy; i++) { it = itom(i); fwrite((double *) &matrix[mtoi(it[0], it[1])], sizeof(double), 1, fd); } free(it); fclose(fd); }
void check_mem (void) { MINT *m; char *s; m = itom (0); s = mtox (m); if (! tests_memory_valid (s)) { printf ("Skipping t-mtox, cannot test libgmp and libmp memory together\n"); exit (0); } mfree (m); (*__gmp_free_func) (s, strlen (s) + 1); }
// Función realizada para testeo unitario void edacortest() { int i; int * it; double * itm; for(i = 0; i < dimx * dimy; i++) { // Transformación de número a coordenada de matriz it = itom(i); // Transformación de coordenada de matriz a coordenada compleja itm = mtoc(it[0], it[1]); mandelbrotjob(i); // printf("Visitando el job nro. %d\ten [%d, %d]\tcomplex [%f, %f] = \t%f\n", i, it[0], it[1], itm[0], itm[1], matrix[it[0]][it[1]]); free(it); free(itm); } }
main() { int i; char *p; uid = getuid(); myname = getlogin(); if(myname == NULL) myname = getpwuid(uid)->pw_name; comminit(); mbuf = itom(0); files(); setup(getpass("Key: ")); mkb(); mkx(); #ifndef debug invert(x, b, x); #else invert(x, b, z); mult(x, z, z); mdiv(z, b, q, z); omout(z); invert(x, b, x); #endif for(i=0; i<fcnt; i++) { sprintf(line, "%s%s.%d", maildir, myname, fnum[i]); if(stat(line, &stbuf)<0) { perror(line); continue; } if(stbuf.st_size == 0) { printf("zero length mail file\n"); unlink(line); continue; } if((mf = fopen(line, "r"))==NULL) { perror(line); continue; } decipher(mf, stdout); cmnd: printf("? "); fgets(buf, sizeof(buf), stdin); if(feof(stdin)) exit(0); switch(buf[0]) { case 'q': exit(0); case 'n': case 'd': case '\n': unlink(line); fclose(mf); break; case '!': system(buf+1); printf("!\n"); goto cmnd; case 's': case 'w': rewind(mf); if(buf[1] == '\n' || buf[1] == '\0') strcpy(buf, "s mbox\n"); for(p=buf; !isspace(*p); p++); for(; isspace(*p); p++); p[strlen(p)-1] = 0; kf = fopen(p, "a"); if(kf == NULL) { perror(p); break; } decipher(mf, kf); fclose(mf); fclose(kf); unlink(line); break; } } exit(0); }
main() { int i; char *p; uid = getuid(); myname = (char *)getlogin(); if(myname == NULL) myname = getpwuid(uid)->pw_name; comminit(); mbuf = itom(0); files(); setup(getpass("Key: ")); mkb(); mkx(); #ifndef debug invert(x, b, x); #else invert(x, b, z); mult(x, z, z); mdiv(z, b, q, z); omout(z); invert(x, b, x); #endif for(i=0; i<fcnt; i++) { sprintf(line, "%s%s.%d", maildir, myname, fnum[i]); if(stat(line, &stbuf)<0) { perror(line); continue; } if(stbuf.st_size == 0) { printf("zero length mail file\n"); unlink(line); continue; } if((mf = fopen(line, "r"))==NULL) { perror(line); continue; } decipher(mf, stdout); cmnd: printf("? "); fgets(buf, sizeof(buf), stdin); if(feof(stdin)) exit(0); switch(buf[0]) { case 'q': exit(0); case 'n': case 'd': case '\n': fclose(mf); unlink(line); break; case '!': system(buf+1); printf("!\n"); goto cmnd; case 's': case 'w': rewind(mf); if(buf[1] == '\n' || buf[1] == '\0') strcpy(buf, "s mbox\n"); for(p = buf+1; isspace(*p); p++); p[strlen(p)-1] = 0; kf = fopen(p, "a"); if(kf == NULL) { perror(p); goto cmnd; } decipher(mf, kf); fclose(mf); fclose(kf); unlink(line); break; default: printf("Commands are:\n"); printf("q quit, leaving unread messages\n"); printf("n delete current message and goto next\n"); printf("d same as above\n"); printf("\\n same as above\n"); printf("! execute shell command\n"); printf("s save message in the named file or mbox\n"); printf("w same as above\n"); printf("? prints this list\n"); goto cmnd; } } exit(0); }