static void setup(void) { tst_require_root(); tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; /* * Get the IDs of all the groups of "root" * from /etc/group file */ ngroups = readgroups(groups); /* Setgroups is called by the login(1) process * if the testcase is executed via an ssh session this * testcase will fail. So execute setgroups() before executing * getgroups() */ if (SETGROUPS(cleanup, ngroups, groups) == -1) tst_brkm(TBROK | TERRNO, cleanup, "setgroups failed"); }
/*============================================================================*/ int main (int argc, char **argv) { /* printf("argc=%d\n", argc); */ #ifdef PROOL if(argc==3) { exitif(strlen(argv[1])>195, "unical: sorry input file name too long.", NULL); strcpy(inname, argv[1]); exitif(strlen(argv[1])>195, "unical: sorry output file name too long.", NULL); strcpy(outname, argv[2]); printf("unical1, Copyright(C) 2011 Bernhardi \n"); printf("some modif. by prool, 2015. www.prool.kharkov.org\n"); printf("unical comes with ABSOLUTELY NO WARRANTY. This is free\n"); printf("software, and you are welcome to redistribute it under\n"); printf("certain conditions, see http://www.gnu.org/licenses/gpl.html\n\n"); } else { printf("unical: usage: unical inputfile outputfile\n"); exit(0); } #else if(argc==2) { exitif(strlen(argv[1])>195, "unical: sorry file name too long.", NULL); strcpy(problem, argv[1]); full=0; } else if(argc==3) { exitif(strncmp(argv[1],"-f",2)!=0, "unical: command not understood.", NULL); exitif(strlen(argv[2])>195, "unical: sorry file name too long.", NULL); strcpy(problem, argv[2]); full=1; } else { printf("unical: usage: unical [-f] unv_filename (without extension .unv)\n"); exit(0); } printf("unical1, Copyright(C) 2011 Bernhardi \n"); printf("unical comes with ABSOLUTELY NO WARRANTY. This is free\n"); printf("software, and you are welcome to redistribute it under\n"); printf("certain conditions, see http://www.gnu.org/licenses/gpl.html\n\n"); strcpy(inname, problem); strcat(inname, ".unv"); #endif #ifdef PROOL process_e(inname); // convert exponent letter D+00 to E+00 strcpy(inname,TMPNAME); #endif printf("unical: Reading from file %s\n",inname); fid = fopen(inname,"r"); exitif(fid==0,"Error reading from file ",inname); countuni(); /* determine number of elements, nodes, etc. */ printf("unical: maxnode=%d, sumele=%d\n", maxnode, sumele); allocate(); /* allocate large arrays. */ rewind(fid); readnodes(); /* read nodes: coordinates. */ rewind(fid); readelements(); /* read element connectivities. */ rewind(fid); readgroups(); /* read group information. */ /* close universal file */ printf("unical: closing universal file %s\n", inname); ret = fclose(fid); exitif(ret < 0,"while attempting to close file ",inname); #ifndef PROOL strcpy(outname, problem); strcat(outname, ".inp"); #endif printf("unical: writing to file %s\n",outname); fid = fopen(outname,"w"); exitif(fid==0,"Error opening file ",outname); writemesh(); /* write node point and element data to abaqus/calculix input file. */ surface(); /* process groups for boundary conditions. */ #ifndef PROOL /* write standard ABAQUS procedure calls: *frequency step. */ fprintf(fid,"*material, name=steel\n"); fprintf(fid,"*elastic\n"); fprintf(fid,"209000.0, 0.3\n"); fprintf(fid,"*density\n"); fprintf(fid,"7.85e-09\n"); fprintf(fid,"*step\n"); fprintf(fid,"*frequency\n"); fprintf(fid,"12\n"); fprintf(fid,"*nodefile\n"); fprintf(fid,"u\n"); fprintf(fid,"*elfile, output=3D\n"); fprintf(fid,"s, e\n"); fprintf(fid,"*endstep\n"); #endif /* close abaqus/calculix input file */ printf("unical: closing file %s\n", outname); ret = fclose(fid); exitif(ret < 0,"while attempting to close file ",outname); printf("unical: It was a pleasure serving you. Bye. \n"); printf("unical: returning to system. \n"); #ifdef PROOL if (remove(TMPNAME)) {printf("can't delete tmp file `%s'\n",TMPNAME); exit(1);} #endif exit(0); }