Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. namespace faces {
  2. enum face {
  3. normal = 0x00,
  4. bold = 0x01,
  5. dark = 0x02,
  6. uline = 0x04,
  7. invert = 0x07,
  8. invisible = 0x08,
  9. cline = 0x09
  10. };
  11. }
  12.  
  13.  
  14. static inline char* set_face_s(char** buff, size_t &size,
  15. faces::face face = faces::normal) {
  16. char* output = *buff;
  17. uintptr_t offset = 0;
  18. assert(size > ( 1 /* '' */
  19. + 2 /* "33[" */
  20. + 1 /* face */
  21. + 1) /* "m" */
  22. && "set_face_s::insufficient memory");
  23. output[0] = '';
  24. strcat(output,"33[");
  25. offset += 2;
  26.  
  27. if (!face) {
  28. strcat(output, "0"); // reset everything
  29. offset+=1;
  30. }
  31. if (face) {
  32. sprintf(output+offset, "%d", face);
  33. }
  34. strcat(output,"m");
  35. offset+=1;
  36. (*buff) += (offset+1);
  37. size -= (offset+1);
  38. return output;
  39. }
  40.  
  41. void f() {
  42. char buffer[1024];
  43. char* arr = buffer;
  44. size_t bytesLeft = 1024;
  45. char* c = strcat(set_face_s(&arr, bytesLeft, faces::uline),
  46. set_face_s(&arr, bytesLeft, faces::bold))
  47. }
  48.  
  49. void g() {
  50. char buffer[1024];
  51. char* arr = buffer;
  52. size_t bytesLeft = 1024;
  53. char* c1 = set_face_s(&arr, bytesLeft, faces::uline);
  54. char* c2 = strcat(c1, set_face_s(&arr, bytesLeft, faces::bold));
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement