00001 #include "log.h"
00002 #include "format.h"
00003 #include "linestream.h"
00004 #include "bp.h"
00005
00011 static LineStream lsBp = NULL;
00012
00013
00018 void bp_init (char* fileName)
00019 {
00020 lsBp = ls_createFromFile (fileName);
00021 }
00022
00023
00028 void bp_deInit (void)
00029 {
00030 ls_destroy (lsBp);
00031 }
00032
00033
00038 Array bp_getBreakPoints (void)
00039 {
00040 Array breakPoints;
00041 BreakPoint *currBP;
00042 char *line,*pos,*token;
00043 Texta tokens;
00044 BreakPointRead *currBPR;
00045 WordIter w;
00046
00047 breakPoints = arrayCreate (100,BreakPoint);
00048 while (line = ls_nextLine (lsBp)) {
00049 if (line[0] == '\0') {
00050 continue;
00051 }
00052 tokens = textStrtok (line,",");
00053 currBP = arrayp (breakPoints,arrayMax (breakPoints),BreakPoint);
00054 currBP->tileCoordinate1 = hlr_strdup (textItem (tokens,0));
00055 currBP->tileCoordinate2 = hlr_strdup (textItem (tokens,1));
00056 currBP->breakPointReads = arrayCreate (100,BreakPointRead);
00057 w = wordIterCreate (textItem (tokens,2),"|",0);
00058 while (token = wordNext (w)) {
00059 pos = strchr (token,':');
00060 *pos = '\0';
00061 currBPR = arrayp (currBP->breakPointReads,arrayMax (currBP->breakPointReads),BreakPointRead);
00062 currBPR->offset = atoi (token);
00063 currBPR->read = hlr_strdup (pos + 1);
00064 }
00065 wordIterDestroy (w);
00066 textDestroy (tokens);
00067 }
00068 return breakPoints;
00069 }
00070
00071
00072
00073
00074
00075
00076
00077 char* bp_writeBreakPoint (BreakPoint *currBP)
00078 {
00079 static Stringa buffer = NULL;
00080 BreakPointRead *currBPR;
00081 int i;
00082
00083 stringCreateClear (buffer,1000);
00084 stringPrintf (buffer,"%s,%s,",currBP->tileCoordinate1,currBP->tileCoordinate2);
00085 for (i = 0; i < arrayMax (currBP->breakPointReads); i++) {
00086 currBPR = arrp (currBP->breakPointReads,i,BreakPointRead);
00087 stringAppendf (buffer,"%d:%s%s",currBPR->offset,currBPR->read, i < arrayMax (currBP->breakPointReads) - 1 ? "|" : "");
00088 }
00089 return string (buffer);
00090 }