/* copenai - Simple curses interface to an OpenAI server Copyright (C) 2025 Ian Cowburn (ianc@noddybox.co.uk) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #include #include #include #include #include /* ---------------------------------------- VERSION INFO */ static const char *usage = "Version 1.0 development\n" "\n" "This program is distributed in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" "GNU General Public License (Version 3) for more details.\n" "\n" "usage: copenai base_url\n"; /* ---------------------------------------- INPUT WINDOW */ static void GetInput(WINDOW *w, int y, int x, int cols, char *dest, size_t destlen) { dest[0] = 0; } /* ---------------------------------------- MAIN CODE */ static void MainCode(const char *url, const char *apikey) { int rows; int cols; WINDOW *input_window; WINDOW *output_window; getmaxyx(stdscr, rows, cols); input_window = newwin(3, cols, 0, 0); output_window = newwin(rows - 3, cols, 3, 0); box(input_window, 0, 0); wrefresh(input_window); } /* ---------------------------------------- MAIN */ int main(int argc, char *argv[]) { const char *url = argv[1]; const char *apikey = getenv("OPENAI_APIKEY"); if (!url) { fprintf(stderr, "%s", usage); return EXIT_FAILURE; } if (!apikey) { fprintf(stderr, "Missing OPENAI_APIKEY from environment\n"); return EXIT_FAILURE; } initscr(); cbreak(); noecho(); keypad(stdscr,TRUE); MainCode(url, apikey); erase(); refresh(); endwin(); return EXIT_SUCCESS; } /* vim: ai sw=4 ts=8 expandtab */