Fox_McCloud Posted August 29, 2002 Share Posted August 29, 2002 The client uses the normal password cmd and i wanna compare it with a var in a .cfg like the TCKmodel.cfg from the jedimod. But i dont understand the hole routine, it is to complex. I was searching for some easy code or a toturial with simple in-/output like the tckmodel.cfg do, nothing found That means I wanna use a .cfg dat with e.g. 3 var's password clientname number password clientname number password clientname number ... and use it: read(buf, len, f) <<-- so the full cfg is in the var buf now i have to call the void, but how??? for (i=1,i=10;i++){ PWGetName(buf[1,i], buf[2,i], buf[3,i]) // i for line... } PLZ, can someone help me?? Link to comment Share on other sites More sharing options...
The Eternal Posted September 6, 2002 Share Posted September 6, 2002 *d arrays (2d, 3d etc..) are accessed using [num][num]etc... so it's probably [j][0] etc. [j,0] wouldn't work in c or c++ (isn't that pascal or something? ) Link to comment Share on other sites More sharing options...
The Eternal Posted September 6, 2002 Share Posted September 6, 2002 also, read reads it into one big character buffer, so if you want to retreive the lines you would have to split the output on the \n (newline) character. which you can do by searching for the amount of newlines, allocating enough memory for that many lines, and then parsing those lines (write to linebuffer, keep incrementing the read buffer and if the read buffer equals \n, increment i.) that's basically it.. hope it helps quick code just to be sure char **cLineBuffer; char *cWalkBuffer; char *cBuffer; int i = 0; // Read the data in the buffer here .... // Read number of lines cWalkBuffer = cBuffer; while( cWalkBuffer ) { if( cWalkBuffer++ == '\n' ) i++; } cLineBuffer = (char**)malloc( sizeof(char*) * i ); // Read in lines i = 0; cWalkBuffer = cBuffer; while( cWalkBuffer ) { if( cWalkBuffer == '\n' ) cLineBuffer[++i] = (char*)malloc( 128 ); cLineBuffer = cWalkBuffer++; } not tested.. but it should 'basically' do the trick you seem to want after this you can walk trough all lines. you could also just increment the line counter by one when you encounter one so you know at what line you are and don't need to create all those silly buffers Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.