Changeset e19eb97 for commands.c


Ignore:
Timestamp:
Aug 15, 2009, 7:08:18 PM (12 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Branches:
master, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
1077891a
Parents:
fa4562c
git-author:
Anders Kaseorg <andersk@mit.edu> (08/04/09 02:37:51)
git-committer:
Anders Kaseorg <andersk@mit.edu> (08/15/09 19:08:18)
Message:
Add const qualifiers for char * and void *.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    rfa4562c re19eb97  
    55#include "owl.h"
    66
    7 /* fn is "char *foo(int argc, char **argv, char *buff)" */
     7/* fn is "char *foo(int argc, const char *const *argv, const char *buff)" */
    88#define OWLCMD_ARGS(name, fn, ctx, summary, usage, description) \
    99        { name, summary, usage, description, ctx, \
     
    2424          actualname, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
    2525
    26 /* fn is "char *foo(void *ctx, int argc, char **argv, char *buff)" */
     26/* fn is "char *foo(void *ctx, int argc, const char *const *argv, const char *buff)" */
    2727#define OWLCMD_ARGS_CTX(name, fn, ctx, summary, usage, description) \
    2828        { name, summary, usage, description, ctx, \
    29           NULL, NULL, NULL, NULL, ((char*(*)(void*,int,char**,char*))fn), NULL, NULL, NULL }
     29          NULL, NULL, NULL, NULL, ((char*(*)(void*,int,const char*const *,const char*))fn), NULL, NULL, NULL }
    3030
    3131/* fn is "void foo(void)" */
     
    10041004}
    10051005
    1006 char *owl_command_help(int argc, char **argv, char *buff)
     1006char *owl_command_help(int argc, const char *const *argv, const char *buff)
    10071007{
    10081008  if (argc!=2) {
     
    10151015}
    10161016
    1017 char *owl_command_zlist(int argc, char **argv, char *buff)
     1017char *owl_command_zlist(int argc, const char *const *argv, const char *buff)
    10181018{
    10191019  int elapsed=0, timesort=0;
    1020   char *file=NULL;
     1020  const char *file=NULL;
    10211021
    10221022  argc--;
     
    10761076}
    10771077
    1078 char *owl_command_aim(int argc, char **argv, char *buff)
     1078char *owl_command_aim(int argc, const char *const *argv, const char *buff)
    10791079{
    10801080  if (argc<2) {
     
    10961096}
    10971097
    1098 char *owl_command_addbuddy(int argc, char **argv, char *buff)
     1098char *owl_command_addbuddy(int argc, const char *const *argv, const char *buff)
    10991099{
    11001100  if (argc!=3) {
     
    11241124}
    11251125
    1126 char *owl_command_delbuddy(int argc, char **argv, char *buff)
     1126char *owl_command_delbuddy(int argc, const char *const *argv, const char *buff)
    11271127{
    11281128  if (argc!=3) {
     
    11481148}
    11491149
    1150 char *owl_command_join(int argc, char **argv, char *buff)
     1150char *owl_command_join(int argc, const char *const *argv, const char *buff)
    11511151{
    11521152  if (argc!=3 && argc!=4) {
     
    11721172}
    11731173
    1174 char *owl_command_startup(int argc, char **argv, char *buff)
    1175 {
    1176   char *ptr;
     1174char *owl_command_startup(int argc, const char *const *argv, const char *buff)
     1175{
     1176  const char *ptr;
    11771177
    11781178  if (argc<2) {
     
    11931193}
    11941194
    1195 char *owl_command_unstartup(int argc, char **argv, char *buff)
    1196 {
    1197   char *ptr;
     1195char *owl_command_unstartup(int argc, const char *const *argv, const char *buff)
     1196{
     1197  const char *ptr;
    11981198
    11991199  if (argc<2) {
     
    12131213}
    12141214
    1215 char *owl_command_dump(int argc, char **argv, char *buff)
     1215char *owl_command_dump(int argc, const char *const *argv, const char *buff)
    12161216{
    12171217  char *filename;
     
    12271227}
    12281228
    1229 char *owl_command_source(int argc, char **argv, char *buff)
     1229char *owl_command_source(int argc, const char *const *argv, const char *buff)
    12301230{
    12311231  if (argc!=2) {
     
    12381238}
    12391239
    1240 char *owl_command_next(int argc, char **argv, char *buff)
     1240char *owl_command_next(int argc, const char *const *argv, const char *buff)
    12411241{
    12421242  char *filter=NULL;
     
    12681268}
    12691269
    1270 char *owl_command_prev(int argc, char **argv, char *buff)
     1270char *owl_command_prev(int argc, const char *const *argv, const char *buff)
    12711271{
    12721272  char *filter=NULL;
     
    12981298}
    12991299
    1300 char *owl_command_smartnarrow(int argc, char **argv, char *buff)
     1300char *owl_command_smartnarrow(int argc, const char *const *argv, const char *buff)
    13011301{
    13021302  char *filtname = NULL;
     
    13161316}
    13171317
    1318 char *owl_command_smartfilter(int argc, char **argv, char *buff)
     1318char *owl_command_smartfilter(int argc, const char *const *argv, const char *buff)
    13191319{
    13201320  char *filtname = NULL;
     
    13721372}
    13731373
    1374 char *owl_command_loadsubs(int argc, char **argv, char *buff)
     1374char *owl_command_loadsubs(int argc, const char *const *argv, const char *buff)
    13751375{
    13761376  if (argc == 2) {
     
    13861386
    13871387
    1388 char *owl_command_loadloginsubs(int argc, char **argv, char *buff)
     1388char *owl_command_loadloginsubs(int argc, const char *const *argv, const char *buff)
    13891389{
    13901390  if (argc == 2) {
     
    14041404}
    14051405
    1406 char *owl_command_start_command(int argc, char **argv, char *buff)
     1406char *owl_command_start_command(int argc, const char *const *argv, const char *buff)
    14071407{
    14081408  buff = skiptokens(buff, 1);
     
    14111411}
    14121412
    1413 char *owl_command_zaway(int argc, char **argv, char *buff)
     1413char *owl_command_zaway(int argc, const char *const *argv, const char *buff)
    14141414{
    14151415  if ((argc==1) ||
     
    14371437
    14381438
    1439 char *owl_command_aaway(int argc, char **argv, char *buff)
     1439char *owl_command_aaway(int argc, const char *const *argv, const char *buff)
    14401440{
    14411441  if ((argc==1) ||
     
    14631463
    14641464
    1465 char *owl_command_away(int argc, char **argv, char *buff)
     1465char *owl_command_away(int argc, const char *const *argv, const char *buff)
    14661466{
    14671467  if ((argc==1) ||
     
    15061506}
    15071507
    1508 char *owl_command_set(int argc, char **argv, char *buff)
    1509 {
    1510   char *var, *val;
     1508char *owl_command_set(int argc, const char *const *argv, const char *buff)
     1509{
     1510  const char *var, *val;
    15111511  int  silent=0;
    15121512  int requirebool=0;
     
    15371537}
    15381538
    1539 char *owl_command_unset(int argc, char **argv, char *buff)
    1540 {
    1541   char *var, *val;
     1539char *owl_command_unset(int argc, const char *const *argv, const char *buff)
     1540{
     1541  const char *var, *val;
    15421542  int  silent=0;
    15431543
     
    15571557}
    15581558
    1559 char *owl_command_print(int argc, char **argv, char *buff)
    1560 {
    1561   char *var;
     1559char *owl_command_print(int argc, const char *const *argv, const char *buff)
     1560{
     1561  const char *var;
    15621562  char valbuff[1024];
    15631563
     
    15821582
    15831583
    1584 char *owl_command_exec(int argc, char **argv, char *buff)
     1584char *owl_command_exec(int argc, const char *const *argv, const char *buff)
    15851585{
    15861586  return owl_function_exec(argc, argv, buff, 0);
    15871587}
    15881588
    1589 char *owl_command_pexec(int argc, char **argv, char *buff)
     1589char *owl_command_pexec(int argc, const char *const *argv, const char *buff)
    15901590{
    15911591  return owl_function_exec(argc, argv, buff, 1);
    15921592}
    15931593
    1594 char *owl_command_aexec(int argc, char **argv, char *buff)
     1594char *owl_command_aexec(int argc, const char *const *argv, const char *buff)
    15951595{
    15961596  return owl_function_exec(argc, argv, buff, 2);
    15971597}
    15981598
    1599 char *owl_command_perl(int argc, char **argv, char *buff)
     1599char *owl_command_perl(int argc, const char *const *argv, const char *buff)
    16001600{
    16011601  return owl_function_perl(argc, argv, buff, 0);
    16021602}
    16031603
    1604 char *owl_command_pperl(int argc, char **argv, char *buff)
     1604char *owl_command_pperl(int argc, const char *const *argv, const char *buff)
    16051605{
    16061606  return owl_function_perl(argc, argv, buff, 1);
    16071607}
    16081608
    1609 char *owl_command_aperl(int argc, char **argv, char *buff)
     1609char *owl_command_aperl(int argc, const char *const *argv, const char *buff)
    16101610{
    16111611  return owl_function_perl(argc, argv, buff, 2);
    16121612}
    16131613
    1614 char *owl_command_multi(int argc, char **argv, char *buff)
     1614char *owl_command_multi(int argc, const char *const *argv, const char *buff)
    16151615{
    16161616  char *lastrv = NULL, *newbuff;
     
    16471647
    16481648
    1649 char *owl_command_alias(int argc, char **argv, char *buff)
     1649char *owl_command_alias(int argc, const char *const *argv, const char *buff)
    16501650{
    16511651  if (argc < 3) {
     
    16591659
    16601660
    1661 char *owl_command_bindkey(int argc, char **argv, char *buff)
     1661char *owl_command_bindkey(int argc, const char *const *argv, const char *buff)
    16621662{
    16631663  owl_keymap *km;
     
    16881688}
    16891689
    1690 char *owl_command_debug(int argc, char **argv, char *buff)
     1690char *owl_command_debug(int argc, const char *const *argv, const char *buff)
    16911691{
    16921692  if (argc<2) {
     
    17041704}
    17051705
    1706 char *owl_command_term(int argc, char **argv, char *buff)
     1706char *owl_command_term(int argc, const char *const *argv, const char *buff)
    17071707{
    17081708  if (argc<2) {
     
    17211721}
    17221722
    1723 char *owl_command_zlog(int argc, char **argv, char *buff)
     1723char *owl_command_zlog(int argc, const char *const *argv, const char *buff)
    17241724{
    17251725  if ((argc<2) || (argc>3)) {
     
    17451745}
    17461746
    1747 char *owl_command_subscribe(int argc, char **argv, char *buff)
    1748 {
    1749   char *class, *instance, *recip="";
     1747char *owl_command_subscribe(int argc, const char *const *argv, const char *buff)
     1748{
     1749  const char *class, *instance, *recip="";
    17501750  int temp=0;
    17511751  int ret=0;
     
    17951795
    17961796
    1797 char *owl_command_unsubscribe(int argc, char **argv, char *buff)
    1798 {
    1799   char *class, *instance, *recip="";
     1797char *owl_command_unsubscribe(int argc, const char *const *argv, const char *buff)
     1798{
     1799  const char *class, *instance, *recip="";
    18001800  int temp=0;
    18011801
     
    18431843}
    18441844
    1845 char *owl_command_echo(int argc, char **argv, char *buff)
     1845char *owl_command_echo(int argc, const char *const *argv, const char *buff)
    18461846{
    18471847  buff = skiptokens(buff, 1);
     
    18601860}
    18611861
    1862 char *owl_command_zwrite(int argc, char **argv, char *buff)
     1862char *owl_command_zwrite(int argc, const char *const *argv, const char *buff)
    18631863{
    18641864  owl_zwrite z;
     
    18841884}
    18851885
    1886 char *owl_command_aimwrite(int argc, char **argv, char *buff)
     1886char *owl_command_aimwrite(int argc, const char *const *argv, const char *buff)
    18871887{
    18881888  char *newbuff, *recip;
    1889   char **myargv;
     1889  const char *const *myargv;
    18901890  int i, j, myargc;
    18911891  owl_message *m;
     
    19641964}
    19651965
    1966 char *owl_command_loopwrite(int argc, char **argv, char *buff)
     1966char *owl_command_loopwrite(int argc, const char *const *argv, const char *buff)
    19671967{
    19681968  owl_function_loopwrite_setup();
     
    19701970}
    19711971
    1972 char *owl_command_zcrypt(int argc, char **argv, char *buff)
     1972char *owl_command_zcrypt(int argc, const char *const *argv, const char *buff)
    19731973{
    19741974#ifdef OWL_ENABLE_ZCRYPT
     
    19981998}
    19991999
    2000 char *owl_command_reply(int argc, char **argv, char *buff)
     2000char *owl_command_reply(int argc, const char *const *argv, const char *buff)
    20012001{
    20022002  int edit=0;
     
    20242024}
    20252025
    2026 char *owl_command_filter(int argc, char **argv, char *buff)
     2026char *owl_command_filter(int argc, const char *const *argv, const char *buff)
    20272027{
    20282028  owl_function_create_filter(argc, argv);
     
    20302030}
    20312031
    2032 char *owl_command_zlocate(int argc, char **argv, char *buff)
     2032char *owl_command_zlocate(int argc, const char *const *argv, const char *buff)
    20332033{
    20342034  int auth;
     
    20642064 * view --home
    20652065 */
    2066 char *owl_command_view(int argc, char **argv, char *buff)
     2066char *owl_command_view(int argc, const char *const *argv, const char *buff)
    20672067{
    20682068  /* First take the 'view --home' and 'view -r' cases */
     
    20882088  /* Now get 'view -d <expression>' */
    20892089  if (argc>=3 && !strcmp(argv[1], "-d")) {
    2090     char **myargv;
     2090    const char **myargv;
    20912091    int i;
    20922092
    2093     myargv=owl_malloc((argc*sizeof(char *))+50);
     2093    myargv=owl_malloc((argc*sizeof(const char *))+50);
    20942094    myargv[0]="";
    20952095    myargv[1]="owl-dynamic";
     
    21362136      argv++;
    21372137    } else if (!strcmp(argv[0], "-r")) {
    2138       char *foo;
     2138      const char *foo;
    21392139      foo=owl_function_create_negative_filter(owl_view_get_filtname(owl_global_get_current_view(&g)));
    21402140      owl_function_change_currentview_filter(foo);
     
    21562156}
    21572157
    2158 char *owl_command_show(int argc, char **argv, char *buff)
     2158char *owl_command_show(int argc, const char *const *argv, const char *buff)
    21592159{
    21602160  if (argc<2) {
     
    22132213    owl_function_show_quickstart();
    22142214  } else if (!strcmp(argv[1], "startup")) {
    2215     char *filename;
     2215    const char *filename;
    22162216   
    22172217    filename=owl_global_get_startupfile(&g);
     
    22262226}
    22272227
    2228 char *owl_command_viewclass(int argc, char **argv, char *buff)
     2228char *owl_command_viewclass(int argc, const char *const *argv, const char *buff)
    22292229{
    22302230  char *filtname;
     
    22392239}
    22402240
    2241 char *owl_command_viewuser(int argc, char **argv, char *buff)
     2241char *owl_command_viewuser(int argc, const char *const *argv, const char *buff)
    22422242{
    22432243  char *filtname;
     
    22582258}
    22592259
    2260 char *owl_command_delete(int argc, char **argv, char *buff)
     2260char *owl_command_delete(int argc, const char *const *argv, const char *buff)
    22612261{
    22622262  int move_after = 1;
     
    22922292}
    22932293
    2294 char *owl_command_undelete(int argc, char **argv, char *buff)
     2294char *owl_command_undelete(int argc, const char *const *argv, const char *buff)
    22952295{
    22962296  int move_after = 1;
     
    23262326}
    23272327
    2328 char *owl_command_colorview(int argc, char **argv, char *buff)
     2328char *owl_command_colorview(int argc, const char *const *argv, const char *buff)
    23292329{
    23302330  if (argc < 2 || argc > 3) {
     
    23362336}
    23372337
    2338 char *owl_command_colorclass(int argc, char **argv, char *buff)
    2339 {
    2340   char *filtname;
     2338char *owl_command_colorclass(int argc, const char *const *argv, const char *buff)
     2339{
     2340  const char *filtname;
    23412341 
    23422342  if (argc < 3 || argc > 4) {
     
    23502350}
    23512351
    2352 char *owl_command_zpunt(int argc, char **argv, char *buff)
     2352char *owl_command_zpunt(int argc, const char *const *argv, const char *buff)
    23532353{
    23542354  owl_command_zpunt_and_zunpunt(argc, argv, 0);
     
    23562356}
    23572357
    2358 char *owl_command_zunpunt(int argc, char **argv, char *buff)
     2358char *owl_command_zunpunt(int argc, const char *const *argv, const char *buff)
    23592359{
    23602360  owl_command_zpunt_and_zunpunt(argc, argv, 1);
     
    23622362}
    23632363
    2364 void owl_command_zpunt_and_zunpunt(int argc, char **argv, int type)
     2364void owl_command_zpunt_and_zunpunt(int argc, const char *const *argv, int type)
    23652365{
    23662366  /* if type==0 then zpunt
    23672367   * if type==1 then zunpunt
    23682368   */
    2369   char *class, *inst, *recip;
     2369  const char *class, *inst, *recip;
    23702370
    23712371  class="message";
     
    23992399}
    24002400
    2401 char *owl_command_smartzpunt(int argc, char **argv, char *buff)
     2401char *owl_command_smartzpunt(int argc, const char *const *argv, const char *buff)
    24022402{
    24032403  if (argc == 1) {
     
    24112411}
    24122412
    2413 char *owl_command_punt(int argc, char **argv, char *buff)
     2413char *owl_command_punt(int argc, const char *const *argv, const char *buff)
    24142414{
    24152415  owl_command_punt_unpunt(argc, argv, buff, 0);
     
    24172417}
    24182418
    2419 char *owl_command_unpunt(int argc, char **argv, char *buff)
     2419char *owl_command_unpunt(int argc, const char *const *argv, const char *buff)
    24202420{
    24212421  owl_command_punt_unpunt(argc, argv, buff, 1);
     
    24232423}
    24242424
    2425 void owl_command_punt_unpunt(int argc, char ** argv, char *buff, int unpunt)
     2425void owl_command_punt_unpunt(int argc, const char *const * argv, const char *buff, int unpunt)
    24262426{
    24272427  owl_list * fl;
     
    24572457
    24582458
    2459 char *owl_command_getview(int argc, char **argv, char *buff)
    2460 {
    2461   char *filtname;
     2459char *owl_command_getview(int argc, const char *const *argv, const char *buff)
     2460{
     2461  const char *filtname;
    24622462  if (argc != 1) {
    24632463    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
     
    24692469}
    24702470
    2471 char *owl_command_getvar(int argc, char **argv, char *buff)
     2471char *owl_command_getvar(int argc, const char *const *argv, const char *buff)
    24722472{
    24732473  char tmpbuff[1024];
     
    24832483}
    24842484
    2485 char *owl_command_getfilter(int argc, char **argv, char *buf)
     2485char *owl_command_getfilter(int argc, const char *const *argv, const char *buf)
    24862486{
    24872487  owl_filter *f;
     
    24972497}
    24982498
    2499 char *owl_command_search(int argc, char **argv, char *buff)
     2499char *owl_command_search(int argc, const char *const *argv, const char *buff)
    25002500{
    25012501  int direction;
    2502   char *buffstart;
     2502  const char *buffstart;
    25032503
    25042504  direction=OWL_DIRECTION_DOWNWARDS;
     
    25182518}
    25192519
    2520 char *owl_command_setsearch(int argc, char **argv, char *buff)
    2521 {
    2522   char *buffstart;
     2520char *owl_command_setsearch(int argc, const char *const *argv, const char *buff)
     2521{
     2522  const char *buffstart;
    25232523
    25242524  buffstart=skiptokens(buff, 1);
     
    25282528}
    25292529
    2530 char *owl_command_aimlogin(int argc, char **argv, char *buff)
     2530char *owl_command_aimlogin(int argc, const char *const *argv, const char *buff)
    25312531{
    25322532  if ((argc<2) || (argc>3)) {
     
    25492549}
    25502550
    2551 char *owl_command_aimlogout(int argc, char **argv, char *buff)
     2551char *owl_command_aimlogout(int argc, const char *const *argv, const char *buff)
    25522552{
    25532553  /* clear the buddylist */
     
    25582558}
    25592559
    2560 char *owl_command_getstyle(int argc, char **argv, char *buff)
    2561 {
    2562   char *stylename;
     2560char *owl_command_getstyle(int argc, const char *const *argv, const char *buff)
     2561{
     2562  const char *stylename;
    25632563  if (argc != 1) {
    25642564    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
     
    25702570}
    25712571
    2572 char *owl_command_error(int argc, char **argv, char *buff)
     2572char *owl_command_error(int argc, const char *const *argv, const char *buff)
    25732573{
    25742574    buff = skiptokens(buff, 1);
     
    25772577}
    25782578
    2579 char *owl_command_message(int argc, char **argv, char *buff)
     2579char *owl_command_message(int argc, const char *const *argv, const char *buff)
    25802580{
    25812581    buff = skiptokens(buff, 1);
     
    25882588  owl_message *m;
    25892589  owl_view *v;
    2590   char *cmd;
     2590  const char *cmd;
    25912591
    25922592  v = owl_global_get_current_view(&g);
     
    26222622  owl_message *m;
    26232623  owl_view *v;
    2624   char *cmd;
     2624  const char *cmd;
    26252625
    26262626  v = owl_global_get_current_view(&g);
     
    26802680{
    26812681  owl_history *hist;
    2682   char *ptr;
     2682  const char *ptr;
    26832683
    26842684  hist=owl_editwin_get_history(e);
     
    27012701{
    27022702  owl_history *hist;
    2703   char *ptr;
     2703  const char *ptr;
    27042704
    27052705  hist=owl_editwin_get_history(e);
     
    27152715}
    27162716
    2717 char *owl_command_edit_insert_text(owl_editwin *e, int argc, char **argv, char *buff)
     2717char *owl_command_edit_insert_text(owl_editwin *e, int argc, const char *const *argv, const char *buff)
    27182718{
    27192719  buff = skiptokens(buff, 1);
Note: See TracChangeset for help on using the changeset viewer.