-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path102-python.c
More file actions
33 lines (27 loc) · 682 Bytes
/
102-python.c
File metadata and controls
33 lines (27 loc) · 682 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* File: 102-python.c
* Auth: Brennan D Baraban
*/
#include "Python.h"
/**
* print_python_string - Prints information about Python strings.
* @p: A PyObject string object.
*/
void print_python_string(PyObject *p)
{
long int length;
fflush(stdout);
printf("[.] string object info\n");
if (strcmp(p->ob_type->tp_name, "str") != 0)
{
printf(" [ERROR] Invalid String Object\n");
return;
}
length = ((PyASCIIObject *)(p))->length;
if (PyUnicode_IS_COMPACT_ASCII(p))
printf(" type: compact ascii\n");
else
printf(" type: compact unicode object\n");
printf(" length: %ld\n", length);
printf(" value: %ls\n", PyUnicode_AsWideCharString(p, &length));
}