summaryrefslogtreecommitdiffstats
path: root/src/pacman/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pacman/util.c')
-rw-r--r--src/pacman/util.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 8dd0f11d..68f39e38 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -49,6 +49,16 @@ extern int maxcols;
extern config_t *config;
extern int neednl;
+/* gets the current screen column width */
+int getcols()
+{
+ const char *cenv = getenv("COLUMNS");
+ if(cenv != NULL) {
+ return atoi(cenv);
+ }
+ return -1;
+}
+
/* does the same thing as 'mkdir -p' */
int makepath(char *path)
{
@@ -126,14 +136,14 @@ int rmrf(char *path)
/* output a string, but wrap words properly with a specified indentation
*/
-void indentprint(char *str, int indent)
+void indentprint(const char *str, int indent)
{
- char *p = str;
+ const char *p = str;
int cidx = indent;
while(*p) {
if(*p == ' ') {
- char *next = NULL;
+ const char *next = NULL;
int len;
p++;
if(p == NULL || *p == ' ') continue;