static void writeConstructor(A2PWriter writer, A2PType expected, ATermAppl constructor){ A2PConstructorType t = (A2PConstructorType) expected->theType; A2PTupleType children = ((A2PTupleType) t->children->theType); int nrOfChildren = typeArraySize(children->fieldTypes); ISIndexedSet sharedTypes = writer->typeSharingMap; int typeHash = hashType(expected); int constructorTypeId = ISget(sharedTypes, (void*) expected, typeHash); int arity = ATgetArity(ATgetAFun(constructor)); int i; if(arity != nrOfChildren){ fprintf(stderr, "Arity (%d) is unequal to the number of children (%d); term was:\n%s\n", arity, nrOfChildren, ATwriteToString((ATerm) constructor)); exit(1);} if(constructorTypeId == -1){ writeByteToBuffer(writer->buffer, PDB_CONSTRUCTOR_HEADER); doWriteType(writer, expected); ISstore(sharedTypes, (void*) expected, typeHash); }else{ writeByteToBuffer(writer->buffer, PDB_CONSTRUCTOR_HEADER | PDB_TYPE_SHARED_FLAG); printInteger(writer->buffer, constructorTypeId); } printInteger(writer->buffer, arity); for(i = 0; i < arity; i++){ doSerialize(writer, children->fieldTypes[i], ATgetArgument(constructor, i)); } }
static void writeTupleType(A2PWriter writer, A2PType tupleType){ A2PTupleType t = (A2PTupleType) tupleType->theType; A2PType *fieldTypes = t->fieldTypes; char **fieldNames = t->fieldNames; int nrOfFields = typeArraySize(fieldTypes); int hasFieldNames = (fieldNames == NULL) ? 0 : 1; int i; if(hasFieldNames == 0){ writeByteToBuffer(writer->buffer, PDB_TUPLE_TYPE_HEADER); printInteger(writer->buffer, nrOfFields); for(i = 0; i < nrOfFields; i++){ writeType(writer, t->fieldTypes[i]); } }else{ writeByteToBuffer(writer->buffer, PDB_TUPLE_TYPE_HEADER | PDB_HAS_FIELD_NAMES); printInteger(writer->buffer, nrOfFields); for(i = 0; i < nrOfFields; i++){ char *fieldName = fieldNames[i]; int fieldNameLength = dataArraySize(fieldName); writeType(writer, t->fieldTypes[i]); printInteger(writer->buffer, fieldNameLength); writeDataToBuffer(writer->buffer, fieldName, fieldNameLength); } } }
void printDouble(double val, uint8_t precision){ if(val < 0.0){ printByte('-'); val = -val; } printInteger((long)val); if(precision > 0) { printByte('.'); unsigned long frac; unsigned long mult = 1; uint8_t padding = precision -1; while(precision--) mult *=10; if(val >= 0) frac = (val - (int)val) * mult; else frac = ((int)val- val) * mult; unsigned long frac1 = frac; while(frac1 /= 10 ) padding--; while(padding--) printByte('0'); printInteger(frac); } }
static void writeSet(A2PWriter writer, A2PType expected, ATermList set){ A2PSetType setType = (A2PSetType) expected->theType; A2PType elementType = setType->elementType; ISIndexedSet sharedTypes = writer->typeSharingMap; int elementHash = hashType(elementType); int elementTypeId = ISget(sharedTypes, (void*) elementType, elementHash); int size = ATgetLength(set); ATermList next; if(elementTypeId == -1){ writeByteToBuffer(writer->buffer, PDB_SET_HEADER); doWriteType(writer, elementType); ISstore(sharedTypes, (void*) elementType, elementHash); }else{ writeByteToBuffer(writer->buffer, PDB_SET_HEADER | PDB_TYPE_SHARED_FLAG); printInteger(writer->buffer, elementTypeId); } printInteger(writer->buffer, size); next = set; while(!ATisEmpty(next)){ ATerm current = ATgetFirst(next); next = ATgetNext(next); doSerialize(writer, elementType, current); } }
static void writeRelation(A2PWriter writer, A2PType expected, ATermList relation){ A2PRelationType relationType = (A2PRelationType) expected->theType; A2PType tupleType = relationType->tupleType; ISIndexedSet sharedTypes = writer->typeSharingMap; int tupleHash = hashType(tupleType); int tupleTypeId = ISget(sharedTypes, (void*) tupleType, tupleHash); int size = ATgetLength(relation); ATermList next; if(tupleTypeId == -1){ writeByteToBuffer(writer->buffer, PDB_RELATION_HEADER); doWriteType(writer, tupleType); ISstore(sharedTypes, (void*) tupleType, tupleHash); }else{ writeByteToBuffer(writer->buffer, PDB_RELATION_HEADER | PDB_TYPE_SHARED_FLAG); printInteger(writer->buffer, tupleTypeId); } printInteger(writer->buffer, size); next = relation; while(!ATisEmpty(next)){ ATerm current = ATgetFirst(next); next = ATgetNext(next); doSerialize(writer, tupleType, current); } }
static void writeNode(A2PWriter writer, A2PType expected, ATermAppl node){ AFun fun = ATgetAFun(node); int arity = ATgetArity(fun); char *name = ATgetName(fun); int i; unsigned int hash = hashString(name); int nodeNameId = ISstore(writer->nameSharingMap, (void*) name, hash); if(nodeNameId == -1){ int nameLength = dataArraySize(name); writeByteToBuffer(writer->buffer, PDB_NODE_HEADER); printInteger(writer->buffer, nameLength); writeDataToBuffer(writer->buffer, name, nameLength); }else{ writeByteToBuffer(writer->buffer, PDB_NODE_HEADER | PDB_NAME_SHARED_FLAG); printInteger(writer->buffer, nodeNameId); } printInteger(writer->buffer, arity); for(i = 0; i < arity; i++){ doSerialize(writer, A2PvalueType(), ATgetArgument(node, i)); } }
static void status_message(int status_code) { if (status_code == 0) { int32_t* pos=get_current_position(); printPgmString(PSTR("ok")); printPgmString(PSTR(" W:")); printInteger(pos[0]); printPgmString(PSTR(" X:")); printInteger(pos[1]); printPgmString(PSTR(" Y:")); printInteger(pos[2]); printPgmString(PSTR(" Z:")); printInteger(pos[3]); printPgmString(PSTR("\r\n")); } else { printPgmString(PSTR("error: ")); switch(status_code) { case STATUS_BAD_NUMBER_FORMAT: printPgmString(PSTR("Bad number format\r\n")); break; case STATUS_EXPECTED_COMMAND_LETTER: printPgmString(PSTR("Expected command letter\r\n")); break; case STATUS_UNSUPPORTED_STATEMENT: printPgmString(PSTR("Unsupported statement\r\n")); break; case STATUS_FLOATING_POINT_ERROR: printPgmString(PSTR("Floating point error\r\n")); break; default: printInteger(status_code); printPgmString(PSTR("\r\n")); } } }
static void writeAnnotatedConstructorType(A2PWriter writer, A2PType constructorType){ A2PConstructorType t = (A2PConstructorType) constructorType->theType; char *name = t->name; int nameLength = dataArraySize(name); HTHashtable hashtable = t->declaredAnnotations; HTIterator iterator = HTcreateIterator(hashtable); int nrOfAnnotations = HTsize(hashtable); HTEntry *nextAnnotation; writeByteToBuffer(writer->buffer, PDB_ANNOTATED_CONSTRUCTOR_TYPE_HEADER); printInteger(writer->buffer, nameLength); writeDataToBuffer(writer->buffer, name, nameLength); writeType(writer, t->children); writeType(writer, t->adt); printInteger(writer->buffer, nrOfAnnotations); while((nextAnnotation = HTgetNext(iterator)) != NULL){ char *label = (char*) nextAnnotation->key; int labelLength = dataArraySize(label); printInteger(writer->buffer, labelLength); writeDataToBuffer(writer->buffer, label, labelLength); writeType(writer, (A2PType) nextAnnotation->value); } }
static void writeAnnotatedNode(A2PWriter writer, A2PType expected, ATermAppl node, ATermList annotations){ A2PNodeType t = (A2PNodeType) expected->theType; AFun fun = ATgetAFun(node); int arity = ATgetArity(fun); char *name = ATgetName(fun); int nrOfAnnotations = ATgetLength(annotations); int i; ATerm annotationLabel; ATerm annotationValue; unsigned int hash = hashString(name); int nodeNameId = ISstore(writer->nameSharingMap, (void*) name, hash); if(nodeNameId == -1){ int nameLength = dataArraySize(name); writeByteToBuffer(writer->buffer, PDB_ANNOTATED_NODE_HEADER); printInteger(writer->buffer, nameLength); writeDataToBuffer(writer->buffer, name, nameLength); }else{ writeByteToBuffer(writer->buffer, PDB_ANNOTATED_NODE_HEADER | PDB_NAME_SHARED_FLAG); printInteger(writer->buffer, nodeNameId); } printInteger(writer->buffer, arity); for(i = 0; i < arity; i++){ doSerialize(writer, A2PvalueType(), ATgetArgument(node, i)); } /* Annotations. */ if((nrOfAnnotations % 2) == 1){ fprintf(stderr, "Detected corrupt annotations (Unbalanced).\n"); exit(1); } printInteger(writer->buffer, nrOfAnnotations); do{ char *label; int labelLength; A2PType annotationType; annotationLabel = ATgetFirst(annotations); annotations = ATgetNext(annotations); annotationValue = ATgetFirst(annotations); annotations = ATgetNext(annotations); if(ATgetType(annotationLabel) != AT_APPL){ fprintf(stderr, "Detected corrupt annotation; label term is not a 'string'.\n"); exit(1); } label = ATgetName(ATgetAFun((ATermAppl) annotationLabel)); labelLength = dataArraySize(label); printInteger(writer->buffer, labelLength); writeDataToBuffer(writer->buffer, label, labelLength); annotationType = (A2PType) HTget(t->declaredAnnotations, (void*) label, hashString(label)); doSerialize(writer, annotationType, annotationValue); }while(!ATisEmpty(annotations)); }
static void writeAnnotatedConstructor(A2PWriter writer, A2PType expected, ATermAppl constructor, ATermList annotations){ A2PConstructorType t = (A2PConstructorType) expected->theType; ISIndexedSet sharedTypes = writer->typeSharingMap; int typeHash = hashType(expected); int constructorTypeId = ISget(sharedTypes, (void*) expected, typeHash); int arity = ATgetArity(ATgetAFun(constructor)); int nrOfAnnotations = ATgetLength(annotations); int i; ATerm annotationLabel; ATerm annotationValue; if(constructorTypeId == -1){ writeByteToBuffer(writer->buffer, PDB_ANNOTATED_CONSTRUCTOR_HEADER); doWriteType(writer, expected); ISstore(sharedTypes, (void*) expected, typeHash); }else{ writeByteToBuffer(writer->buffer, PDB_ANNOTATED_CONSTRUCTOR_HEADER | PDB_TYPE_SHARED_FLAG); printInteger(writer->buffer, constructorTypeId); } printInteger(writer->buffer, arity); for(i = 0; i < arity; i++){ doSerialize(writer, ((A2PTupleType) t->children->theType)->fieldTypes[i], ATgetArgument(constructor, i)); } /* Annotations. */ if((nrOfAnnotations % 2) == 1){ fprintf(stderr, "Detected corrupt annotations (Unbalanced).\n"); exit(1); } printInteger(writer->buffer, nrOfAnnotations); do{ char *label; int labelLength; A2PType annotationType; annotationLabel = ATgetFirst(annotations); annotations = ATgetNext(annotations); annotationValue = ATgetFirst(annotations); annotations = ATgetNext(annotations); if(ATgetType(annotationLabel) != AT_APPL){ fprintf(stderr, "Detected corrupt annotation; label term is not a 'string'.\n"); exit(1); } label = ATgetName(ATgetAFun((ATermAppl) annotationLabel)); labelLength = dataArraySize(label); printInteger(writer->buffer, labelLength); writeDataToBuffer(writer->buffer, label, labelLength); annotationType = (A2PType) HTget(t->declaredAnnotations, (void*) label, hashString(label)); doSerialize(writer, annotationType, annotationValue); }while(!ATisEmpty(annotations)); }
// Print current gcode parser mode state void report_gcode_modes() { switch (gc.motion_mode) { case MOTION_MODE_SEEK : printPgmString(PSTR("[G0")); break; case MOTION_MODE_LINEAR : printPgmString(PSTR("[G1")); break; case MOTION_MODE_CW_ARC : printPgmString(PSTR("[G2")); break; case MOTION_MODE_CCW_ARC : printPgmString(PSTR("[G3")); break; case MOTION_MODE_CANCEL : printPgmString(PSTR("[G80")); break; } printPgmString(PSTR(" G")); printInteger(gc.coord_select+54); if (gc.plane_axis_0 == X_AXIS) { if (gc.plane_axis_1 == Y_AXIS) { printPgmString(PSTR(" G17")); } else { printPgmString(PSTR(" G18")); } } else { printPgmString(PSTR(" G19")); } if (gc.inches_mode) { printPgmString(PSTR(" G20")); } else { printPgmString(PSTR(" G21")); } if (gc.absolute_mode) { printPgmString(PSTR(" G90")); } else { printPgmString(PSTR(" G91")); } if (gc.inverse_feed_rate_mode) { printPgmString(PSTR(" G93")); } else { printPgmString(PSTR(" G94")); } switch (gc.program_flow) { case PROGRAM_FLOW_RUNNING : printPgmString(PSTR(" M0")); break; case PROGRAM_FLOW_PAUSED : printPgmString(PSTR(" M1")); break; case PROGRAM_FLOW_COMPLETED : printPgmString(PSTR(" M2")); break; } switch (gc.spindle_direction) { case SPINDLE_ENABLE_CW : printPgmString(PSTR(" M3")); break; case SPINDLE_ENABLE_CCW : printPgmString(PSTR(" M4")); break; case SPINDLE_DISABLE : printPgmString(PSTR(" M5")); break; } switch (gc.coolant_mode) { case COOLANT_DISABLE : printPgmString(PSTR(" M9")); break; case COOLANT_FLOOD_ENABLE : printPgmString(PSTR(" M8")); break; #ifdef ENABLE_M7 case COOLANT_MIST_ENABLE : printPgmString(PSTR(" M7")); break; #endif } printPgmString(PSTR(" T")); printInteger(gc.tool); printPgmString(PSTR(" F")); if (gc.inches_mode) { printFloat(gc.feed_rate*INCH_PER_MM); } else { printFloat(gc.feed_rate); } printPgmString(PSTR("]\r\n")); }
// Parse the next token from the input stream. void getsym(void) { // dispatch to handler for this type of char (*tokenhandlers[chartype(inchar)])(); #ifdef PARSER_TRACE if (trace) { sp(" sym="); printInteger(sym); sp(" v="); printInteger(symval); spb(' '); } #endif }
static void writeBool(A2PWriter writer, ATermAppl boolean){ char *boolName = ATgetName(ATgetAFun(boolean)); writeByteToBuffer(writer->buffer, PDB_BOOL_HEADER); if(strncmp(boolName, "true", 4) == 0){ printInteger(writer->buffer, 1); }else{ printInteger(writer->buffer, 0); } }
void settings_dump() { printPgmString(PSTR("$0 = ")); printFloat(settings.steps_per_mm[X_AXIS]); printPgmString(PSTR(" (steps/mm x)\r\n$1 = ")); printFloat(settings.steps_per_mm[Y_AXIS]); printPgmString(PSTR(" (steps/mm y)\r\n$2 = ")); printFloat(settings.steps_per_mm[Z_AXIS]); printPgmString(PSTR(" (steps/mm z)\r\n$3 = ")); printInteger(settings.pulse_microseconds); printPgmString(PSTR(" (microseconds step pulse)\r\n$4 = ")); printFloat(settings.default_feed_rate); printPgmString(PSTR(" (mm/min default feed rate)\r\n$5 = ")); printFloat(settings.default_seek_rate); printPgmString(PSTR(" (mm/min default seek rate)\r\n$6 = ")); printFloat(settings.mm_per_arc_segment); printPgmString(PSTR(" (mm/arc segment)\r\n$7 = ")); printInteger(settings.invert_mask); printPgmString(PSTR(" (step port invert mask. binary = ")); printIntegerInBase(settings.invert_mask, 2); printPgmString(PSTR(")\r\n$8 = ")); printFloat(settings.acceleration/(60*60)); // Convert from mm/min^2 for human readability printPgmString(PSTR(" (acceleration in mm/sec^2)\r\n$9 = ")); printFloat(settings.junction_deviation); printPgmString(PSTR(" (cornering junction deviation in mm)")); printPgmString(PSTR("\r\n'$x=value' to set parameter or just '$' to dump current settings\r\n")); }
int main(void) { ConfigPins(); initUART(); initSysTick(); RValue = initAccel(); printInteger(RValue); if (RValue == 0) { printString("Boldly going :)\r\n"); } else { printString("Inertia sensors offline :(\r\n"); } while (1) { Temperature = getTemperature(); printShort(Temperature); printString(" "); getMotion(&m); printShort(m.x_a); printString(" "); printShort(m.y_a); printString(" "); printShort(m.z_a); printString(" "); printString("\r\n"); GPIO0DATA ^= BIT2; delay(10000); } return 0; }
void kill(int process) { setKernelDataSegment(); p[process].active=0; printInteger(p[process].active); restoreDataSegment(); }
static void writeInteger(A2PWriter writer, ATermInt integer){ int intValue = ATgetInt(integer); writeByteToBuffer(writer->buffer, PDB_INTEGER_HEADER); printInteger(writer->buffer, intValue); }
// Fetch and return the next char from input stream. void fetchc(void) { // terrible horrible eeprom addressing kludge if (isram(fetchptr)) { if (*fetchptr) fetchptr++; inchar = *fetchptr; } else { // fetch char from eeprom int addr = dekludge(fetchptr); inchar = eeread(addr); if ((inchar != 0) && (inchar != 255)) { inchar = eeread(++addr); fetchptr = kludge(addr); // save incremented pointer if (inchar == 255) inchar = 0; } } #ifdef PARSER_TRACE // char trace if (trace) { //spb('['); printInteger(inchar);spb(':'); if (inchar) spb(inchar); spb(']'); spb('['); if (inchar >= 0x20) spb(inchar); else { spb('\\'); printInteger(inchar); } spb(']'); } #endif //return inchar; }
// Prints specified startup line void report_startup_line (uint8_t n, char* line) { printPgmString (PSTR ("$N") ); printInteger (n); printPgmString (PSTR ("=") ); printString (line); printPgmString (PSTR ("\r\n") ); }
static void status_message(int status_code) { if (status_code == 0) { printPgmString(PSTR("ok\r\n")); } else { printPgmString(PSTR("error: ")); switch(status_code) { case STATUS_BAD_NUMBER_FORMAT: printPgmString(PSTR("Bad number format\r\n")); break; case STATUS_EXPECTED_COMMAND_LETTER: printPgmString(PSTR("Expected command letter\r\n")); break; case STATUS_UNSUPPORTED_STATEMENT: printPgmString(PSTR("Unsupported statement\r\n")); break; case STATUS_FLOATING_POINT_ERROR: printPgmString(PSTR("Floating point error\r\n")); break; case STATUS_MODAL_GROUP_VIOLATION: printPgmString(PSTR("Modal group violation\r\n")); break; case STATUS_INVALID_COMMAND: printPgmString(PSTR("Invalid command\r\n")); break; default: printInteger(status_code); printPgmString(PSTR("\r\n")); } } }
/* * print( n ) - prints a 64-bit number adding an EOL and a carriage return * */ void WaspUSB::println(uint64_t n) { secureBegin(); printInteger(n,0); printNewline(_uart); secureEnd(); }
static void writeString(A2PWriter writer, ATermAppl string){ char *stringValue = ATgetName(ATgetAFun(string)); int stringValueLength = dataArraySize(stringValue); writeByteToBuffer(writer->buffer, PDB_STRING_HEADER); printInteger(writer->buffer, stringValueLength); writeDataToBuffer(writer->buffer, stringValue, stringValueLength); }
void printInteger(View *view, int value, int x, int y, Color mainColor, Color shadowColor) { if (value>0) { printInteger(view, value/10, x-8, y, mainColor, shadowColor); printChar(view, (char)(value%10 + 48), x, y, mainColor, shadowColor); } else if (value == 0) { printChar(view, '0', x, y, mainColor, shadowColor); } }
void printInteger(Sheet *sheet, int value, int x, int y, Color color) { if (value>0) { printInteger(sheet, value/10, x-8, y, color); printChar(sheet, (char)(value%10 + 48), x, y, color); } else if (value == 0) { printChar(sheet, '0', x, y, color); } }
void showTaskList(void) { byte slot; for (slot = 0; slot < NUMTASKS; slot++) { if (tasklist[slot] != SLOT_FREE) { printInteger(slot, 0, ' '); spb(':'); spb(' '); eeputs(tasklist[slot]); speol(); } } }
// Prints real-time data. This function grabs a real-time snapshot of the stepper subprogram // and the actual location of the CNC machine. Users may change the following function to their // specific needs, but the desired real-time data report must be as short as possible. This is // requires as it minimizes the computational overhead and allows grbl to keep running smoothly, // especially during g-code programs with fast, short line segments and high frequency reports (5-20Hz). void report_realtime_status() { // **Under construction** Bare-bones status report. Provides real-time machine position relative to // the system power on location (0,0,0) and work coordinate position (G54 and G92 applied). Eventually // to be added are distance to go on block, processed block id, and feed rate. Also a settings bitmask // for a user to select the desired real-time data. uint8_t i; int32_t current_position[N_AXIS]; // Copy current state of the system position variable memcpy(current_position,sys.position,sizeof(sys.position)); float print_position[N_AXIS]; // Report current machine state switch (sys.state) { case STATE_IDLE: printPgmString(PSTR("<Idle")); break; case STATE_QUEUED: printPgmString(PSTR("<Queue")); break; case STATE_CYCLE: printPgmString(PSTR("<Run")); break; case STATE_HOLD: printPgmString(PSTR("<Hold")); break; case STATE_HOMING: printPgmString(PSTR("<Home")); break; case STATE_ALARM: printPgmString(PSTR("<Alarm")); break; case STATE_CHECK_MODE: printPgmString(PSTR("<Check")); break; } // Report machine position printPgmString(PSTR(",MPos:")); for (i=0; i< N_AXIS; i++) { print_position[i] = current_position[i]/settings.steps_per_mm[i]; if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) { print_position[i] *= INCH_PER_MM; } printFloat(print_position[i]); printPgmString(PSTR(",")); } // Report work position printPgmString(PSTR("WPos:")); for (i=0; i< N_AXIS; i++) { if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) { print_position[i] -= (gc.coord_system[i]+gc.coord_offset[i])*INCH_PER_MM; } else { print_position[i] -= gc.coord_system[i]+gc.coord_offset[i]; } printFloat(print_position[i]); if (i < (N_AXIS-1)) { printPgmString(PSTR(",")); } } #ifdef USE_LINE_NUMBERS // Report current line number printPgmString(PSTR(",Ln:")); int32_t ln=0; plan_block_t * pb = plan_get_current_block(); if(pb != NULL) { ln = pb->line_number; } printInteger(ln); #endif printPgmString(PSTR(">\r\n")); }
int main(int argc, char ** argv) { if (argc < 4) { printf("need four file names: type, input, output"); return EXIT_FAILURE; } if (strcmp(argv[1], "i") == 0) /* sort integers */ { int numInteger = 0; int * arrInteger = NULL; arrInteger = readInteger(argv[2], & numInteger); if (numInteger == 0) { return EXIT_FAILURE; } printInteger(arrInteger, numInteger); sortInteger(arrInteger, numInteger); printInteger(arrInteger, numInteger); saveInteger(argv[3], arrInteger, numInteger); freeInteger(arrInteger, numInteger); return EXIT_SUCCESS; } if (strcmp(argv[1], "s") == 0) /* sort strings */ { int numString = 0; char * * arrString = NULL; arrString = readString(argv[2], & numString); if (numString == 0) { return EXIT_FAILURE; } printString(arrString, numString); sortString(arrString, numString); printString(arrString, numString); saveString(argv[3], arrString, numString); freeString(arrString, numString); return EXIT_SUCCESS; } /* unknown type */ return EXIT_FAILURE; }
static void writeADTType(A2PWriter writer, A2PType adtType){ A2PAbstractDataType t = (A2PAbstractDataType) adtType->theType; char *name = t->name; int nameLength = dataArraySize(name); writeByteToBuffer(writer->buffer, PDB_ADT_TYPE_HEADER); printInteger(writer->buffer, nameLength); writeDataToBuffer(writer->buffer, name, nameLength); writeType(writer, A2PvoidType()); }
static void writeAnnotatedNodeType(A2PWriter writer, A2PType nodeType){ A2PNodeType t = (A2PNodeType) nodeType->theType; HTHashtable hashtable = t->declaredAnnotations; HTIterator iterator = HTcreateIterator(hashtable); int nrOfAnnotations = HTsize(hashtable); HTEntry *nextAnnotation; writeByteToBuffer(writer->buffer, PDB_ANNOTATED_NODE_TYPE_HEADER); printInteger(writer->buffer, nrOfAnnotations); while((nextAnnotation = HTgetNext(iterator)) != NULL){ char *label = (char*) nextAnnotation->key; int labelLength = dataArraySize(label); printInteger(writer->buffer, labelLength); writeDataToBuffer(writer->buffer, label, labelLength); writeType(writer, (A2PType) nextAnnotation->value); } }
void printf(const char *format, ...) { va_list val; va_start(val, format); while (*format && *(format + 1)) { if (*format == '%') { format++; char character = *format; if (character == 'd') { int tempd = va_arg(val, int); printInteger(tempd, PRINT_CONTINIOUS); } else if (character == 'x') {